groupBy<T extends Record> method

Group<T, (Expr<A>, Expr<B>, Expr<C>, Expr<D>)> groupBy<T extends Record>(
  1. T groupBuilder(
    1. Expr<A> a,
    2. Expr<B> b,
    3. Expr<C> c,
    4. Expr<D> d,
    )
)

Create projection for GROUP BY clause.

The groupBuilder must return a Record where all the values are Expr objects. If something else is returned you will get a Group object which doesn't have any methods!

This returns a Group object which has an .aggregate method that returns a query with a row for each distinct value of the projetion created by groupBuilder. The .aggregate method is used to construct aggregate functions over rows of this Query for each group.

Implementation

Group<T, (Expr<A>, Expr<B>, Expr<C>, Expr<D>)> groupBy<T extends Record>(
  T Function(Expr<A> a, Expr<B> b, Expr<C> c, Expr<D> d) groupBuilder,
) {
  final (handle, (group, standins)) = _build((a, b, c, d) {
    return (groupBuilder(a, b, c, d), (a, b, c, d));
  });
  return Group._(this, handle, group, standins);
}