rel8-0.1.0.0: Hey! Hey! Can u rel8?
Safe HaskellNone
LanguageHaskell2010

Rel8.Aggregate.Legacy

Synopsis

Documentation

class Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs Source #

Aggregates a b means that the columns in a are all Aggregate Exprs for the columns in b.

Instances

Instances details
Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs Source # 
Instance details

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.