Select preload-field in Ecto Query

Is it possible to do select on preload in ecto query ?
e.g.

query = from p in Post, preload: [:comments], select: map(p, [:comments, :title])
Repo.all(query)
comments_query =
  from Comment, select: [:data]

query =
  from p in Post,
  preload: [comments: ^comments_query],
  select: map(p, [:comments, :title])

Should do the job.

1 Like