Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ecto, preloadでソート
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
You can’t perform that action at this time.