Created
July 29, 2016 07:18
-
-
Save hykw/06507f42d2782f99b34e4f5da5c7317f to your computer and use it in GitHub Desktop.
ecto, preloadでソート
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
child_query = from c in Child, order_by: c.code | |
query = from p in Parent, | |
where p.id == ^id, | |
order_by: p.date, | |
preload: [child: ^child_query] | |
case Repo.all(query) do | |
nil -> {:not_found} | |
record -> {:ok, record} | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment