Last active
April 11, 2017 06:57
-
-
Save holin/0aa721c347b41f9531f386dc69ed6d7f to your computer and use it in GitHub Desktop.
ecto query examples
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
# 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