Created
October 23, 2018 22:58
-
-
Save jjn1056/36507e4af688953fe23eb202d86ffedc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| sub latest_posts ($self) { | |
| $self->Q->published_posts | |
| ->include_author | |
| ->latest(10) | |
| ->hashes->all; | |
| } | |
| same as ??? | |
| select | |
| post.*, | |
| json_agg(comments), | |
| json_agg(author) | |
| from posts post | |
| left join comments on comments.post_id = post.id | |
| join users author on author.username = post.author_username | |
| where post.is_published is true | |
| group by post.id, author.id | |
| order by post.published_at DESC | |
| limit 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment