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

Firestore Count() query #353

Open
spyr0s opened this issue Aug 12, 2023 · 2 comments
Open

Firestore Count() query #353

spyr0s opened this issue Aug 12, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@spyr0s
Copy link

spyr0s commented Aug 12, 2023

Is your feature request related to a problem? Please describe.
I have a problem when I want to get a count of documents of a specific condition
For example get the players that have a score > 10.000, or that signed in after a specific date etc

Describe the solution you'd like
Support the count query of firestore

Describe alternatives you've considered
No alternatives, getting all the documents paginated and count them is out of the question

@spyr0s spyr0s added the enhancement New feature or request label Aug 12, 2023
@BearDooks
Copy link
Member

@spyr0s if you run the query and store the result, can't you just run the size option on the array?

Example

var query: FirestoreQuery = FirestoreQuery.new()
query.from("players")
query.where("chipgamehandicap", FirestoreQuery.OPERATOR.GREATER_THAN, 4)
var result: Array = yield(Firebase.Firestore.query(query), "result_query")
print(result.size())

Or am I way off mark here?

@WolfgangSenff
Copy link
Collaborator

@BearDooks - you should be right, but it might be weird with timing and stuff where it'll not be atomic I guess. I'll have to look into this closer, and am going to do so today while I work on the Firestore huge refactor!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants