Document where_
commitb31e84ee7ff559dd3dd28bed1be058ce1b6efb6c
authorOllie Charles <ollie@ocharles.org.uk>
dateTue 23 Mar 2021, 16:21 (6 years ago)
parent6267132
src/Rel8/Query/Filter.hs+10
@@ -24,6 +24,16 @@ filter :: (a -> Expr Bool) -> a -> Query a
2424filter f a = a <$ where_ (f a)
2525
2626
27+-- | Drop any rows that don't match a predicate. @where_ expr@ is equivalent
28+-- to the SQL @WHERE expr@.
29+--
30+-- >>> :{
31+-- select c $ do
32+-- x <- values [ lit x | x <- [ 1..5 :: Int32 ] ]
33+-- where_ $ x >. lit 2
34+-- return x
35+-- :}
36+-- [3,4,5]
2737where_ :: Expr Bool -> Query ()
2838where_ condition =
2939 fromOpaleye $ lmap (\_ -> toColumn $ toPrimExpr condition) Opaleye.restrict