AggregateFunction

AggregateFunction

A class that represents an aggregate function.

Constructor

new AggregateFunction()

Methods

as(name)

Assigns an alias to this AggregateFunction. The alias specifies the name that the aggregated value will have in the output document.

// Calculate the average price of all items and assign it the alias "averagePrice".
firestore.pipeline().collection("items")
  .aggregate(field("price").average().as("averagePrice"));
Parameters:
Name Type Description
name

The alias to assign to this AggregateFunction.

Returns:
Type Description

A new AliasedAggregate that wraps this AggregateFunction and associates it with the provided alias.