A class that represents an aggregate function.
Signature:
export declare class AggregateFunction
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(name, params) | Constructs a new instance of the AggregateFunction class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| exprType | ExpressionType |
Methods
| Method | Modifiers | Description |
|---|---|---|
| as(name) | Assigns an alias to this AggregateFunction. The alias specifies the name that the aggregated value will have in the output document. |
AggregateFunction.(constructor)
Constructs a new instance of the AggregateFunction class
Signature:
constructor(name: string, params: Expression[]);
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | |
| params | Expression[] |
AggregateFunction.exprType
Signature:
exprType: ExpressionType;
AggregateFunction.as()
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"));