Ecto.Query.API.exists
You're seeing just the function
exists
, go back to Ecto.Query.API module for more information.
Evaluates to true if the provided subquery returns 1 or more rows.
from p in Post,
as: :post,
where:
exists(
from(
c in Comment,
where: parent_as(:post).id == c.post_id and c.replies_count > 5,
select: 1
)
)
This is best used in conjunction with parent_as
to correlate the subquery
with the parent query to test some condition on related rows in a different table.
In the above example the query returns posts which have at least one comment that
has more than 5 replies.