Skip to content

Instantly share code, notes, and snippets.

@sergey-chechaev
Created May 14, 2019 21:11
Show Gist options
  • Save sergey-chechaev/542e251ebafe6894e69cd542685f6cfb to your computer and use it in GitHub Desktop.
Save sergey-chechaev/542e251ebafe6894e69cd542685f6cfb to your computer and use it in GitHub Desktop.
can't preload in one query
def list_user_posts(user_id) do
Post
|> where([p], p.user_id == ^user_id)
|> preload(post_photos: ^from(p in PostPhoto, order_by: p.position))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment