1{-# language FlexibleContexts #-}
3module Rel8.Query.Aggregate
10import Data.Int ( Int64 )
14import qualified Opaleye.Aggregate as Opaleye
17import Rel8.Aggregate ( Aggregate )
18import Rel8.Expr ( Expr )
19import Rel8.Expr.Aggregate ( countStar )
20import Rel8.Query ( Query )
21import Rel8.Query.Maybe ( optional )
22import Rel8.Query.Opaleye ( mapOpaleye )
23import Rel8.Table.Opaleye ( aggregator )
24import Rel8.Table.Maybe ( maybeTable )
27-- | Apply an aggregation to all rows returned by a 'Query'.
28aggregate :: Query (Aggregate exprs) -> Query exprs
29aggregate = mapOpaleye (Opaleye.aggregate aggregator)
32countRows :: Query a -> Query (Expr Int64)
33countRows = fmap (maybeTable 0 id) . optional . aggregate . fmap (const countStar)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list