Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

getCountFromServer

Calculates the number of documents in the result set of the given query without actually downloading the documents.

Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).

The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server.

function getCountFromServer<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<AggregateQuerySnapshot<{
count: AggregateField<number>;
}
, AppModelType, DbModelType>
>
;
§
getCountFromServer<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<AggregateQuerySnapshot<{
count: AggregateField<number>;
}
, AppModelType, DbModelType>
>
[src]

§Type Parameters

§
AppModelType
[src]
§
DbModelType extends DocumentData
[src]

§Parameters

§
query: Query<AppModelType, DbModelType>
[src]

The query whose result set size is calculated.

§Return Type

§
Promise<AggregateQuerySnapshot<{
count: AggregateField<number>;
}
, AppModelType, DbModelType>
>
[src]

A Promise that will be resolved with the count; the count can be retrieved from snapshot.data().count, where snapshot is the AggregateQuerySnapshot to which the returned Promise resolves.