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.
§Parameters
§Return Type
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.