@@ -23,6 +23,19 @@ import Rel8.Table.Eq ( EqTable, (==:) )
23import Rel8.Table.Maybe ( isJustTable )
23import Rel8.Table.Maybe ( isJustTable )
26+-- | Checks if a query returns at least one row.
29+-- mapM_ print =<< select c do
30+-- author <- each authorSchema
31+-- hasProjects <- exists do
32+-- project <- each projectSchema
33+-- where_ $ authorId author ==. projectAuthorId project
34+-- return (authorName author, hasProjects)
37+-- ("Bryan O'Sullivan",True)
38+-- ("Emily Pillmore",False)
26exists :: Query a -> Query (Expr Bool)
39exists :: Query a -> Query (Expr Bool)
27exists = fmap isJustTable . optional . whereExists
40exists = fmap isJustTable . optional . whereExists
28-- FIXME: change this when b7aacc07c6392654cae439fc3b997620c3aa7a87 makes it
41-- FIXME: change this when b7aacc07c6392654cae439fc3b997620c3aa7a87 makes it