Class Pipelines.AggregateFunction (9.3.1)

A class that represents an aggregate function.

Implements

HasUserData

Package

@google-cloud/firestore

Constructors

(constructor)(name, params)

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

Constructs a new instance of the AggregateFunction class

Parameters
Name Description
name string
params Expression[]

Properties

_protoValueType

_protoValueType: "ProtoValue";

expressionType

expressionType: firestore.Pipelines.ExpressionType;

Methods

as(name)

as(name: string): AliasedAggregate;

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"));
Parameter
Name Description
name string

The alias to assign to this AggregateFunction.

Returns
Type Description
AliasedAggregate

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