Hello peeps, I feel this query isn’t concise (or isn’t Ecto-y) enough:
def list_posts_for(tag_id) do
query =
from(pt in PostTag,
where: pt.tag_id == ^tag_id,
left_join: p in Post,
on: p.id == pt.post_id,
select: p
)
Repo.all(query)
end
Posts and tags have many to many relationships + a join schema, and Ecto knows all about them.
Is it possible to start the query with from p in Post
? Other ideas are welcome too.