Constructor
new AggregateQuery(query)
Build an AggregateQuery object.
Parameters:
| Name | Type | Description |
|---|---|---|
query |
Query |
A Query object |
Methods
addAggregation(aggregation) → {AggregateQuery}
Add a custom aggregation to the list of aggregations.
Parameters:
| Name | Type | Description |
|---|---|---|
aggregation |
AggregateField |
The aggregate field to perform the aggregation query over. |
Returns:
| Type | Description |
|---|---|
| AggregateQuery |
addAggregations(aggregations) → {AggregateQuery}
Add a list of custom aggregations to the list of aggregations.
Parameters:
| Name | Type | Description |
|---|---|---|
aggregations |
Array.<AggregateField> |
The aggregate fields to perform the aggregation query over. |
Returns:
| Type | Description |
|---|---|
| AggregateQuery |
average(property, alias) → {AggregateQuery}
Add a average aggregate query to the list of aggregations.
Parameters:
| Name | Type | Description |
|---|---|---|
property |
string |
The property to use for the average calculation. |
alias |
string |
The label used in the results to describe this aggregate field when a query is run. |
Returns:
| Type | Description |
|---|---|
| AggregateQuery |
count(alias) → {AggregateQuery}
Add a count aggregate query to the list of aggregations.
Parameters:
| Name | Type | Description |
|---|---|---|
alias |
string |
The label used in the results to describe this aggregate field when a query is run. |
Returns:
| Type | Description |
|---|---|
| AggregateQuery |
run(optionsOrCallbackopt, cb) → {void|Promise.<RunQueryResponse>}
Run the aggregation query and return the results.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
optionsOrCallback |
RunQueryOptions | RequestCallback |
<optional> |
|
cb |
function |
The callback function. |
Returns:
| Type | Description |
|---|---|
| void | Promise.<RunQueryResponse> |
sum(property, alias) → {AggregateQuery}
Add a sum aggregate query to the list of aggregations.
Parameters:
| Name | Type | Description |
|---|---|---|
property |
string |
The property to use for the sum calculation. |
alias |
string |
The label used in the results to describe this aggregate field when a query is run. |
Returns:
| Type | Description |
|---|---|
| AggregateQuery |
toProto()
Get the proto for the list of aggregations.