aggregateWithAliases method
Returns an AggregateQuery that calculates the given aggregations over the result set of this query, with results keyed by user-chosen aliases:
final snapshot = await query.aggregateWithAliases({
'total': AggregateField.sum('price'),
'n': AggregateField.count(),
}).get();
snapshot.data(); // {'total': 42, 'n': 3}
Any string is a valid alias (aliases are not sent to the server) and the same aggregation may appear under several aliases.
Implementation
AggregateQuery aggregateWithAliases(Map<String, AggregateField> aggregates) {
if (aggregates.isEmpty) {
throw ArgumentError('At least one AggregateField is required.');
}
return AggregateQuery.withAliases(this, aggregates);
}