This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
A class that represents an aggregate function.
Signature:
export declare class AggregateFunction
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(name, params) | (Public Preview) Constructs a new instance of the AggregateFunction class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| exprType | ExpressionType | (Public Preview) |
Methods
| Method | Modifiers | Description |
|---|---|---|
| as(name) | (Public Preview) Assigns an alias to this AggregateFunction. The alias specifies the name that the aggregated value will have in the output document. |
AggregateFunction.(constructor)
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Constructs a new instance of the AggregateFunction class
Signature:
constructor(name: string, params: Expression[]);
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | |
| params | Expression[] |
AggregateFunction.exprType
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Signature:
exprType: ExpressionType;
AggregateFunction.as()
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Assigns an alias to this AggregateFunction. The alias specifies the name that the aggregated value will have in the output document.
Signature:
as(name: string): AliasedAggregate;
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | The alias to assign to this AggregateFunction. |
Returns:
A new AliasedAggregate that wraps this AggregateFunction and associates it with the provided alias.
Example
// Calculate the average price of all items and assign it the alias "averagePrice".
firestore.pipeline().collection("items")
.aggregate(field("price").average().as("averagePrice"));