I'm trying to find domains that don't have any usernames with a given name, that is free domains. Hopefully there's a solution to this that doesn't require 2 separate queries, but I also ran into a problem with type system.
-- error Couldn't match type 'IO [Domain]' with '[[Domain]]', points to beginning of filter
Just term -> do
usernames <- query @Username
|> filterWhere (#name, term) |> fetch >>= collectionFetchRelated #domainId
domains <- search |> filter \x->case find (\y->get #domainId x == get #domainId y) usernames of
Just _ -> True
Nothing -> False
render IndexView {..}