docs-devsite/firestore_lite_pipelines.aggregatefunction.md
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 %}
A class that represents an aggregate function.
<b>Signature:</b>
export declare class AggregateFunction
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(name, params) | Constructs a new instance of the <code>AggregateFunction</code> class |
| Property | Modifiers | Type | Description |
|---|---|---|---|
| exprType | ExpressionType |
| 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. |
Constructs a new instance of the AggregateFunction class
<b>Signature:</b>
constructor(name: string, params: Expression[]);
| Parameter | Type | Description |
|---|---|---|
| name | string | |
| params | Expression<!-- -->[] |
<b>Signature:</b>
exprType: ExpressionType;
Assigns an alias to this AggregateFunction. The alias specifies the name that the aggregated value will have in the output document.
<b>Signature:</b>
as(name: string): AliasedAggregate;
| Parameter | Type | Description |
|---|---|---|
| name | string | The alias to assign to this AggregateFunction. |
<b>Returns:</b>
A new AliasedAggregate that wraps this AggregateFunction and associates it with the provided alias.
// Calculate the average price of all items and assign it the alias "averagePrice".
firestore.pipeline().collection("items")
.aggregate(field("price").average().as("averagePrice"));