Created
August 3, 2018 12:34
-
-
Save geekuillaume/6033b88e94561ffc975c5dd6cb63db5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT todo_lists.id AS id, | |
todo_lists.name, | |
jsonb_agg(to_jsonb(todo_items) - 'todo_list_id') AS items | |
FROM todo_lists | |
LEFT JOIN todo_items ON todo_items.todo_list_id = todo_lists.id | |
GROUP BY todo_lists.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent! 👍🏻