Golang, PostgreSQL and array_agg

If you have SQL like this:

Then you can query DB like this:

And scan results like this (you should not omit errors in real code):

Now you have a list of chats with all it’s users.

You can read more here — https://www.opsdash.com/blog/postgres-arrays-golang.html

LEAVE A COMMENT