Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs
- aggregate :: Aggregates aggregates exprs => Query aggregates -> Query exprs
- aggregateTabulation :: (EqTable k, Aggregates aggregates exprs) => (t -> aggregates) -> Tabulation k t -> Tabulation k exprs
- groupBy :: forall exprs aggregates. (EqTable exprs, Aggregates aggregates exprs) => exprs -> aggregates
- listAgg :: Aggregates aggregates exprs => exprs -> ListTable aggregates
- nonEmptyAgg :: Aggregates aggregates exprs => exprs -> NonEmptyTable aggregates
Documentation
class Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs Source #
Instances
Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs Source # | |
Defined in Rel8.Aggregate |
aggregate :: Aggregates aggregates exprs => Query aggregates -> Query exprs Source #
Apply an aggregation to all rows returned by a Query
.
aggregateTabulation :: (EqTable k, Aggregates aggregates exprs) => (t -> aggregates) -> Tabulation k t -> Tabulation k exprs Source #
groupBy :: forall exprs aggregates. (EqTable exprs, Aggregates aggregates exprs) => exprs -> aggregates Source #
Group equal tables together. This works by aggregating each column in the
given table with groupByExpr
.
listAgg :: Aggregates aggregates exprs => exprs -> ListTable aggregates Source #
Aggregate rows into a single row containing an array of all aggregated rows. This can be used to associate multiple rows with a single row, without changing the over cardinality of the query. This allows you to essentially return a tree-like structure from queries.
For example, if we have a table of orders and each orders contains multiple items, we could aggregate the table of orders, pairing each order with its items:
ordersWithItems :: Query (Order Expr, ListTable (Item Expr)) ordersWithItems = do order <- each orderSchema items aggregate $ listAgg <$ itemsFromOrder order return (order, items)
nonEmptyAgg :: Aggregates aggregates exprs => exprs -> NonEmptyTable aggregates Source #
Like listAgg
, but the result is guaranteed to be a non-empty list.