mirror of
https://github.com/hanzoai/firebase-js-sdk.git
synced 2026-09-24 16:59:10 +00:00
2.6 KiB
2.6 KiB
Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
AggregateFunction class
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"));