on master help sign in
Document Rel8.Query.Limit
6267132Ollie Charles
src/Rel8/Query/Limit.hs+10
@@ -15,9 +15,19 @@ import Rel8.Query ( Query )
15import Rel8.Query.Opaleye ( mapOpaleye )
15import Rel8.Query.Opaleye ( mapOpaleye )
16
16
17
17
18+-- | @limit n@ select at most @n@ rows from a query. @limit n@ is equivalent
19+-- to the SQL @LIMIT n@.
20+--
21+-- >>> select c $ limit 3 $ values [ lit x | x <- [ 1..5 :: Int32 ] ]
22+-- [1,2,3]
18limit :: Word -> Query a -> Query a
23limit :: Word -> Query a -> Query a
19limit = mapOpaleye . Opaleye.limit . fromIntegral
24limit = mapOpaleye . Opaleye.limit . fromIntegral
20
25
21
26
27+-- | @offset n@ drops the first @n@ rows from a query. @offset n@ is equivalent
28+-- to the SQL @OFFSET n@.
29+--
30+-- >>> select c $ offset 3 $ values [ lit x | x <- [ 1..5 :: Int32 ] ]
31+-- [4,5]
22offset :: Word -> Query a -> Query a
32offset :: Word -> Query a -> Query a
23offset = mapOpaleye . Opaleye.offset . fromIntegral
33offset = mapOpaleye . Opaleye.offset . fromIntegral