Skip to content

Instantly share code, notes, and snippets.

@coline-carle
Created February 22, 2018 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coline-carle/a23c2b29c9c91bf2cbda8f04db4c9b55 to your computer and use it in GitHub Desktop.
Save coline-carle/a23c2b29c9c91bf2cbda8f04db4c9b55 to your computer and use it in GitHub Desktop.
ecto join table
defp pinned_raid_with_members(query) do
query
|> where(pinned: true)
|> join(:left, [raid], registrations in assoc(raid, :registrations))
|> join(:left, [raid, registrations], member in assoc(registrations, :member))
|> preload([raid, registrations, member], registrations: {registrations, member: member})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment