Menu
Firestore.projects.databases.documents.run Aggregation Query
Runs an aggregation query. Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side. High-Level Example: ``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```
POST
/v1/{parent}:runAggregationQueryUse it in a workflow
- Add a step and choose the Firestore connector.
- Pick the Firestore.projects.databases.documents.run Aggregation Query action (under projects).
- Fill in the fields below, then reference the result from later steps as
{{firestoreProjectsDatabasesDocumentsRunAggregationQuery.response.data}}.
Request
Path parameters
Query parameters
Request body
Enter the body as JSON in the step's Body field.
{
"newTransaction": {
"readOnly": {
"readTime": "string"
},
"readWrite": {
"retryTransaction": "string"
}
},
"readTime": "string",
"structuredAggregationQuery": {
"aggregations": [
{
"alias": "string",
"count": {
"upTo": "string"
}
}
],
"structuredQuery": {
"endAt": {
"before": false,
"values": [
{
"arrayValue": {
"values": null
},
"booleanValue": false,
"bytesValue": "string",
"doubleValue": 0,
"geoPointValue": {
"latitude": null,
"longitude": null
},
"integerValue": "string",
"mapValue": {
"fields": null
},
"nullValue": "NULL_VALUE",
"referenceValue": "string",
"stringValue": "string",
"timestampValue": "string"
}
]
},
"from": [
{
"allDescendants": false,
"collectionId": "string"
}
],
"limit": 0,
"offset": 0,
"orderBy": [
{
"direction": "DIRECTION_UNSPECIFIED",
"field": {
"fieldPath": "string"
}
}
],
"select": {
"fields": [
{
"fieldPath": "string"
}
]
},
"startAt": {
"before": false,
"values": [
{
"arrayValue": {
"values": null
},
"booleanValue": false,
"bytesValue": "string",
"doubleValue": 0,
"geoPointValue": {
"latitude": null,
"longitude": null
},
"integerValue": "string",
"mapValue": {
"fields": null
},
"nullValue": "NULL_VALUE",
"referenceValue": "string",
"stringValue": "string",
"timestampValue": "string"
}
]
},
"where": {
"compositeFilter": {
"filters": [
{}
],
"op": "OPERATOR_UNSPECIFIED"
},
"fieldFilter": {
"field": {
"fieldPath": "string"
},
"op": "OPERATOR_UNSPECIFIED",
"value": {
"arrayValue": {
"values": null
},
"booleanValue": false,
"bytesValue": "string",
"doubleValue": 0,
"geoPointValue": {
"latitude": null,
"longitude": null
},
"integerValue": "string",
"mapValue": {
"fields": null
},
"nullValue": "NULL_VALUE",
"referenceValue": "string",
"stringValue": "string",
"timestampValue": "string"
}
},
"unaryFilter": {
"field": {
"fieldPath": "string"
},
"op": "OPERATOR_UNSPECIFIED"
}
}
}
},
"transaction": "string"
}
Response
Returns 200 with an object. Read it in later steps with {{firestoreProjectsDatabasesDocumentsRunAggregationQuery.response.data.<field>}}.
{
"readTime": "string",
"result": {
"aggregateFields": {}
},
"transaction": "string"
}
Need more? See the Firestore guide for connection setup and behaviour shared by every action.
Was this page helpful?