Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the count() aggregation #151

Open
u2002020021 opened this issue Dec 8, 2022 · 0 comments
Open

Use the count() aggregation #151

u2002020021 opened this issue Dec 8, 2022 · 0 comments

Comments

@u2002020021
Copy link

u2002020021 commented Dec 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant