Cloud Firestore Client - Class AggregateQuery (1.53.0)
Stay organized with collections
Save and categorize content based on your preferences.
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 |
connection |
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 |
Aggregate
Aggregation over the provided query.
|
addAggregation
Adds provided aggregation to AggregateQuery.
Parameter |
Name |
Description |
aggregate |
Aggregate
Aggregate properties to be applied over query.
|
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
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Firestore Client - Class AggregateQuery (1.53.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.53.0 (latest)](/php/docs/reference/cloud-firestore/latest/AggregateQuery)\n- [1.52.0](/php/docs/reference/cloud-firestore/1.52.0/AggregateQuery)\n- [1.51.0](/php/docs/reference/cloud-firestore/1.51.0/AggregateQuery)\n- [1.50.0](/php/docs/reference/cloud-firestore/1.50.0/AggregateQuery)\n- [1.48.1](/php/docs/reference/cloud-firestore/1.48.1/AggregateQuery)\n- [1.47.3](/php/docs/reference/cloud-firestore/1.47.3/AggregateQuery)\n- [1.46.0](/php/docs/reference/cloud-firestore/1.46.0/AggregateQuery)\n- [1.45.2](/php/docs/reference/cloud-firestore/1.45.2/AggregateQuery)\n- [1.44.1](/php/docs/reference/cloud-firestore/1.44.1/AggregateQuery)\n- [1.43.3](/php/docs/reference/cloud-firestore/1.43.3/AggregateQuery)\n- [1.40.0](/php/docs/reference/cloud-firestore/1.40.0/AggregateQuery)\n- [1.39.0](/php/docs/reference/cloud-firestore/1.39.0/AggregateQuery)\n- [1.38.0](/php/docs/reference/cloud-firestore/1.38.0/AggregateQuery)\n- [1.37.7](/php/docs/reference/cloud-firestore/1.37.7/AggregateQuery)\n- [1.36.1](/php/docs/reference/cloud-firestore/1.36.1/AggregateQuery)\n- [1.35.0](/php/docs/reference/cloud-firestore/1.35.0/AggregateQuery)\n- [1.34.0](/php/docs/reference/cloud-firestore/1.34.0/AggregateQuery)\n- [1.33.0](/php/docs/reference/cloud-firestore/1.33.0/AggregateQuery)\n- [1.32.0](/php/docs/reference/cloud-firestore/1.32.0/AggregateQuery)\n- [1.31.0](/php/docs/reference/cloud-firestore/1.31.0/AggregateQuery)\n- [1.30.0](/php/docs/reference/cloud-firestore/1.30.0/AggregateQuery)\n- [1.28.0](/php/docs/reference/cloud-firestore/1.28.0/AggregateQuery)\n- [1.27.3](/php/docs/reference/cloud-firestore/1.27.3/AggregateQuery) \nReference documentation and code samples for the Cloud Firestore Client class AggregateQuery.\n\nA Cloud Firestore Aggregate Query.\n\nExample: \n\n use Google\\Cloud\\Firestore\\FirestoreClient;\n\n $firestore = new FirestoreClient();\n\n $collection = $firestore-\u003ecollection('users');\n $query = $collection-\u003ewhere('age', '\u003e', 18)-\u003ecount();\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Firestore\n\nMethods\n-------\n\n### __construct\n\nCreate an aggregation query.\n\n### addAggregation\n\nAdds provided aggregation to AggregateQuery.\n\n### getSnapshot\n\nExecutes the AggregateQuery."]]