AggregateQuery

AggregateQuery

An AggregateQuery is a class that can be used to obtain results from an aggregate query request.

Constructor

new AggregateQuery(query)

Build an AggregateQuery object.

Parameters:
Name Type Description
query Query
See:

Methods

addAggregation(aggregation) → {AggregateQuery}

Add a custom aggregation to the list of aggregations.

Parameters:
Name Type Description
aggregation AggregateField
Returns:
Type Description
AggregateQuery

addAggregations(aggregation) → {AggregateQuery}

Add a list of custom aggregations to the list of aggregations.

Parameters:
Name Type Description
aggregation Array.<AggregateField>
Returns:
Type Description
AggregateQuery

average(property, alias) → {AggregateQuery}

Add a average aggregate query to the list of aggregations.

Parameters:
Name Type Description
property string
alias string
Returns:
Type Description
AggregateQuery

count(alias) → {AggregateQuery}

Add a count aggregate query to the list of aggregations.

Parameters:
Name Type Description
alias string
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
alias string
Returns:
Type Description
AggregateQuery

toProto()

Get the proto for the list of aggregations.