feat(firestore): support queries in getCountFromServer#988
Open
robingenz wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Firestore plugin’s getCountFromServer API to support counting documents for queries (not just whole collections) by adding optional compositeFilter and queryConstraints, and wiring them through Web, iOS, and Android implementations using the same query-building patterns as getCollection.
Changes:
- Add
compositeFilterandqueryConstraintstoGetCountFromServerOptions(TypeScript definitions + README docs). - Web: reuse the existing
buildCollectionQueryhelper forgetCountFromServer. - iOS/Android: apply composite filters and query constraints before executing the server aggregation count.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/firestore/src/web.ts | Routes getCountFromServer through the shared query builder to support filters/constraints. |
| packages/firestore/src/definitions.ts | Extends GetCountFromServerOptions with compositeFilter and queryConstraints. |
| packages/firestore/README.md | Documents the newly supported options for getCountFromServer. |
| packages/firestore/ios/Plugin/FirebaseFirestorePlugin.swift | Passes compositeFilter/queryConstraints from the Capacitor call into native options. |
| packages/firestore/ios/Plugin/FirebaseFirestore.swift | Builds a Query with filters/constraints before count.getAggregation(source: .server). |
| packages/firestore/ios/Plugin/Classes/Options/GetCountFromServerOptions.swift | Parses/holds the new query-related options. |
| packages/firestore/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/firestore/FirebaseFirestorePlugin.java | Passes compositeFilter/queryConstraints into native options. |
| packages/firestore/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/firestore/FirebaseFirestore.java | Builds a Query with filters/constraints before calling query.count(). |
| packages/firestore/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/firestore/classes/options/GetCountFromServerOptions.java | Parses/holds the new query-related options. |
| .changeset/firestore-count-from-server-query.md | Declares a minor bump for the new capability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1 task
@capacitor-firebase/analytics
@capacitor-firebase/app
@capacitor-firebase/app-check
@capacitor-firebase/authentication
@capacitor-firebase/crashlytics
@capacitor-firebase/firestore
@capacitor-firebase/functions
@capacitor-firebase/messaging
@capacitor-firebase/performance
@capacitor-firebase/remote-config
@capacitor-firebase/storage
commit: |
This was referenced May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
compositeFilterandqueryConstraintstoGetCountFromServerOptionsso callers can count documents in a filtered/limited query, not only entire collections.getCollectionalready uses.Closes #984
Test plan
getCountFromServerwith onlyreference(existing behavior unchanged).getCountFromServerwith acompositeFilter(and/or) and verify the count matches a filteredgetCollection.getCountFromServerwithqueryConstraints(e.g.where,limit) and verify the count.