computeAggregates<T> function
AggregateResult
computeAggregates<T>(
- List<
T> rows, - List<
Aggregation> aggregations, - Object? read(
- T row,
- String field
Runs every aggregation in aggregations over rows.
Implementation
AggregateResult computeAggregates<T>(
List<T> rows,
List<Aggregation> aggregations,
Object? Function(T row, String field) read,
) {
if (aggregations.isEmpty) return const AggregateResult.empty();
final out = <String, Object?>{};
for (final aggregation in aggregations) {
out[aggregation.id] = aggregation
.apply([for (final row in rows) read(row, aggregation.field)]);
}
return AggregateResult(out);
}