AggregateFunction class

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:

exportdeclareclassAggregateFunction

Constructors

ConstructorModifiersDescription
(constructor)(name, params)(Public Preview) Constructs a new instance of theAggregateFunction class

Properties

PropertyModifiersTypeDescription
exprTypeExpressionType(Public Preview)

Methods

MethodModifiersDescription
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 theAggregateFunction class

Signature:

constructor(name:string,params:Expression[]);

Parameters

ParameterTypeDescription
namestring
paramsExpression[]

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

ParameterTypeDescription
namestringThe alias to assign to this AggregateFunction.

Returns:

AliasedAggregate

A newAliasedAggregate 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"));

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-15 UTC.