DEV Community

Discussion on: SQL Join vs Subquery: The Game Changer

Collapse
 
defman profile image
Sergey Kislyakov

So what jsonb_agg does to e.g. this set of data:

article.id | article.title | comment.id | comment.content |
1 | Some title | 1 | some comment |
1 | Some title | 2 | some comment |
1 | Some title | 3 | some comment |
Enter fullscreen mode Exit fullscreen mode

... is something like this?

article.id | article.title | comments::json |
1 | Some title | [{id: 1, content: "some comment}, ...]
Enter fullscreen mode Exit fullscreen mode

If so, today I learned that Postgres has ORM-like capabilities.

Collapse
 
idoshamun profile image
Ido Shamun

Exactly! I should have added some data examples