@@ -46,10 +46,34 @@ inQuery :: EqTable a => a -> Query a -> Query (Expr Bool)
46inQuery a = exists . (>>= filter (a ==:))
46inQuery a = exists . (>>= filter (a ==:))
49+-- | Produce the empty query if the given query returns no rows. @whereExists@
50+-- is equivalent to @WHERE EXISTS@ in SQL.
54+-- author <- each authorSchema
56+-- project <- each projectSchema
57+-- where_ $ projectAuthorId project ==. authorId author
58+-- return $ authorName author
60+-- ["Ollie","Bryan O'Sullivan"]
49whereExists :: Query a -> Query ()
61whereExists :: Query a -> Query ()
50whereExists = mapOpaleye Opaleye.restrictExists
62whereExists = mapOpaleye Opaleye.restrictExists
65+-- | Produce the empty query if the given query returns rows. @whereNotExists@
66+-- is equivalent to @WHERE NOT EXISTS@ in SQL.
70+-- author <- each authorSchema
72+-- project <- each projectSchema
73+-- where_ $ projectAuthorId project ==. authorId author
74+-- return $ authorName author
53whereNotExists :: Query a -> Query ()
77whereNotExists :: Query a -> Query ()
54whereNotExists = mapOpaleye Opaleye.restrictNotExists
78whereNotExists = mapOpaleye Opaleye.restrictNotExists