Cloud Firestore Client - Class AggregateQuery (1.38.0)

Reference documentation and code samples for the Cloud Firestore Client class AggregateQuery.

A Cloud Firestore Aggregate Query.

Example:

use Google\Cloud\Firestore\FirestoreClient;

$firestore = new FirestoreClient();

$collection = $firestore->collection('users');
$query = $collection->where('age', '>', 18)->count();

Namespace

Google \ Cloud \ Firestore

Methods

__construct

Create an aggregation query.

Parameters
NameDescription
connection Google\Cloud\Firestore\Connection\ConnectionInterface

A Connection to Cloud Firestore. This object is created by FirestoreClient, and should not be instantiated outside of this client.

parent string

The parent of the query.

query array

Represents the underlying structured query.

aggregate Google\Cloud\Firestore\Aggregate

Aggregation over the provided query.

addAggregation

Adds provided aggregation to AggregateQuery.

Parameter
NameDescription
aggregate Google\Cloud\Firestore\Aggregate

Aggregate properties to be applied over query.

Returns
TypeDescription
Google\Cloud\Firestore\AggregateQuery

getSnapshot

Executes the AggregateQuery.

Parameters
NameDescription
options array

Configuration options is an array.

↳ readTime Timestamp

Reads entities as they were at the given timestamp.

Returns
TypeDescription
Google\Cloud\Firestore\AggregateQuerySnapshot