AggregateQuerySnapshot class
The results of executing an AggregateQuery.
Read each result with the AggregateField that asked for it:
final AggregateQuerySnapshot snapshot = await firestore
.collection('orders')
.aggregate(<AggregateField>[
AggregateField.count(),
AggregateField.average('total'),
])
.get();
final int? count = snapshot.count;
final double? average = snapshot.getAverage('total');
The results come from the server at the time of the request; they do not include local writes that are still pending.
Properties
- count → int?
-
The result of the count aggregation (
count()or AggregateField.count), or null when the query did not ask for it.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- query → AggregateQuery
-
The query that produced this snapshot.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
data(
) → Map< String, Object?> -
All results of this snapshot: each value is an
int, adoubleor null, as returned by get. -
get(
AggregateField aggregateField) → Object? -
The result of
aggregateField: anint, adoubleor null (for example the average over no numeric values). -
getAverage(
Object field) → double? -
The result of AggregateField.average over
field(a String or a FieldPath), or null when no document has a numeric value for the field. -
getSum(
Object field) → num? -
The result of AggregateField.sum over
field(a String or a FieldPath): anintfor a sum of integers that fits in 64 bits, adoubleotherwise, or null (for example a sum over no numeric value). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
Two snapshots are equal when they aggregate the same query and hold the
same results under the same names (as
aggregateQuerySnapshotEqualof the JS SDK): the order the aggregations were asked in does not matter.override