I have the following function for finding public trips:
def for_public(query, true) do
query
|> join(:left, [t], p in Permission, on: p.trip_id == t.id, as: :permission)
|> where([permission: p], p.is_public == true)
end
How can I get the opposite of this? (Any trip that does not have a permission with is_public
)
Is it possible to create a not exists
with the pipes?
This is obviously wrong, but what I’m trying to do:
def for_public(query, false) do
query
|> join(:left, [t], p in Permission, on: p.trip_id == t.id, as: :permission)
|> where(not exists([permission: p], p.is_public == true))
end
Thanks!