Created
March 19, 2015 21:27
-
-
Save paulcsmith/2615513d0602915fb98b to your computer and use it in GitHub Desktop.
Complex Ecto Queries with joins and deep preload
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
def with_sorted_comments do | |
from a in Announcement, | |
left_join: c in assoc(a, :comments), | |
left_join: u in assoc(c, :user), | |
order_by: [asc: c.inserted_at], | |
preload: [:interests, :user, comments: {c, user: u}] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment