UNPKG

firelordjs

Version:

🔥 High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience

25 lines (24 loc) • 1.24 kB
import { getCountFromServer as getCountFromServer_ } from 'firebase/firestore'; /** * 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 even * count the documents if the result set would be prohibitively large to * download entirely (e.g. 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 request using this source necessarily involves a round trip to * the server. * * @param query - The query whose result set size to calculate. * @returns 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. */ // @ts-expect-error export var getCountFromServer = getCountFromServer_;