Class AggregateField (7.2.0)

Represents an aggregation that can be performed by Firestore.

Package

@google-cloud/firestore

Remarks

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the AggregateField class.

Properties

aggregateType

readonly aggregateType: AggregateType;

type

readonly type = "AggregateField";

A type string to uniquely identify instances of this class.

Methods

average(field)

static average(field: string | FieldPath): AggregateField<number | null>;

Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

Parameter
NameDescription
field string | FieldPath

Specifies the field to average across the result set.

Returns
TypeDescription
AggregateField<number | null>

count()

static count(): AggregateField<number>;

Create an AggregateField object that can be used to compute the count of documents in the result set of a query.

Returns
TypeDescription
AggregateField<number>

isEqual(other)

isEqual(other: AggregateField<T>): boolean;

Compares this object with the given object for equality.

This object is considered "equal" to the other object if and only if other performs the same kind of aggregation on the same field (if any).

Parameter
NameDescription
other AggregateField<T>

The object to compare to this object for equality. true if this object is "equal" to the given object, as defined above, or false otherwise.

Returns
TypeDescription
boolean

sum(field)

static sum(field: string | FieldPath): AggregateField<number>;

Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

Parameter
NameDescription
field string | FieldPath

Specifies the field to sum across the result set.

Returns
TypeDescription
AggregateField<number>