Skip to content

Instantly share code, notes, and snippets.

@holin
Last active April 11, 2017 06:57
Show Gist options
  • Save holin/0aa721c347b41f9531f386dc69ed6d7f to your computer and use it in GitHub Desktop.
Save holin/0aa721c347b41f9531f386dc69ed6d7f to your computer and use it in GitHub Desktop.
ecto query examples
# Query with preload and join
```elixir
q = from l in List,
join: ul in UserList,
where: ul.user_id == ^current_user.id and l.id == ul.list_id,
order_by: [desc: l.done_at, asc: l.id]
lists = q |> preload(:user) |> Repo.all
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment