Reference documentation and code samples for the Cloud Firestore Client class Aggregate.
Represents Aggregate properties.
Example:
$count = Aggregate::count();
$count->alias('count');
echo json_encode($count->getProps());
Namespace
Google \ Cloud \ FirestoreMethods
alias
Set the aggregate alias.
Example:
$count = Aggregate->count();
$count->alias('total');
echo $count->props()['alias'];
alias
string
The alias for aggregate.
getProps
Get the array representation for the aggregate.
array
static::count
Creates count aggregation properties.
Example:
$count = Aggregate::count();
static::sum
Creates sum aggregation properties.
Example:
$sum = Aggregate::sum('field_to_aggregate_upon');
Result of SUM aggregation can be a integer or a float.
Sum of integers which exceed maxinum integer value returns a float.
Sum of numbers exceeding max float value returns INF
.
Sum of data which contains NaN
returns NaN
.
Non numeric values are ignored.
field
string
The relative path of the field to aggregate upon.
static::avg
Creates average aggregation properties.
Example:
$avg = Aggregate::avg('field_to_aggregate_upon');
Result of AVG aggregation can be a float or a null.
Average of empty valid data set return null
.
Average of numbers exceeding max float value returns INF
.
Average of data which contains NaN
returns NaN
.
Non numeric values are ignored.
field
string|null
The relative path of the field to aggregate upon.