Skip to content

Use the count() aggregation #151

Open
@u2002020021

Description

@u2002020021

Hello :

Google add the count() aggregation query to count, please add this aggregation.

For example, count() operations that match between 0 and 1000 index entries are billed for one document read. For a count() operation that matches 1500 index entries, you are billed 2 document reads.

const coll = collection(db, "cities");
const query_ = query(coll, where('state', '==', 'CA'));
const snapshot = await getCountFromServer(query_);
console.log('count: ', snapshot.data().count);

https://firebase.google.com/docs/firestore/query-data/aggregation-queries#web-version-9_1

https://firebase.google.com/docs/firestore/pricing#aggregation_queries

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions