# Cloud Firestore Client - Class AggregateQuery (2.2.0-RC1)

2.2.0-RC1 2.1.0 (latest) 2.0.2-RC1 1.55.0 1.54.4 1.53.1 1.52.0 1.51.0 1.50.0 1.48.1 1.47.3 1.46.0 1.45.2 1.44.1 1.43.3 1.40.0 1.39.0 1.38.0 1.37.7 1.36.1 1.35.0 1.34.0 1.33.0 1.32.0 1.31.0 1.30.0 1.28.0 1.27.3 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** ||
|---|---|
| **Name** | **Description** |
| `firestoreClient` | `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.Client.FirestoreClient` A FirestoreClient instance. |
| `parent` | `string` The parent of the query. |
| `query` | `array` Represents the underlying structured query. |
| `aggregate` | `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/Aggregate` Aggregation over the provided query. |

### addAggregation

Adds provided aggregation to AggregateQuery.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `aggregate` | `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/Aggregate` Aggregate properties to be applied over query. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/AggregateQuery` |   |

### getSnapshot

Executes the AggregateQuery.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` Configuration options is an array. |
| `↳ readTime` | `Timestamp` Reads entities as they were at the given timestamp. |
| `↳ explainOptions` | `ExplainOptions` An instance of the ExplainOptions class. ExplainOptions} \</xref |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/AggregateQuerySnapshot` |   |