aggregate<T extends Record> method

Query<T> aggregate<T extends Record>(
  1. Aggregation<(Expr<F>, Expr<G>, Expr<H>), T> aggregationBuilder(
    1. Aggregation<(Expr<F>, Expr<G>, Expr<H>), (Expr<A>, Expr<B>, Expr<C>, Expr<D>, Expr<E>)> agg
    )
)

Finish GROUP BY clause by specifying aggregate functions.

Groups are determined by the projection created with the .groupBy projection. Aggregate functions over rows within each group are specified using the aggregationBuilder callback.

The resulting query will have a row for each distinct value of the projection created with .groupBy. Each row will contain the .groupBy projection and any aggregate functions built with aggregationBuilder.

Implementation

Query<T> aggregate<T extends Record>(
  Aggregation<(Expr<F>, Expr<G>, Expr<H>), T> Function(
    Aggregation<
      (Expr<F>, Expr<G>, Expr<H>),
      (Expr<A>, Expr<B>, Expr<C>, Expr<D>, Expr<E>)
    >
    agg,
  )
  aggregationBuilder,
) {
  final agg = aggregationBuilder(Aggregation._(_standins, _group));

  return Query._(
    _from._context,
    agg._projection,
    (e) => GroupByClause._(
      _from._from(_from._expressions.toList()),
      _handle,
      e.take(5).toList(),
      e.skip(5).toList(),
    ),
  );
}