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

Wiki update for query of a subcollection #454

Open
grimberet opened this issue Jan 24, 2025 · 0 comments
Open

Wiki update for query of a subcollection #454

grimberet opened this issue Jan 24, 2025 · 0 comments

Comments

@grimberet
Copy link

I am requesting an update to the wiki for doing a query of a subcollection. It looks like some work has been done to make this possible, but it was very difficult to find after digging through the addon files to discover these features exist. It would be a shame for a user with less experience to not understand or discover these features just because it wasn't listed on the wiki.

The features I am talking about is the FirestoreQuery.sub_collection_path property which allows a string to nest the collection query to a sub path.

The other feature which is required is in the FirestoreQuery.from('collection',false) to override the default allDescendants=true because otherwise the query will cause an error regarding indexes for collection groups. I'm sure someone could change the indexes for these but that doesn't seem practical with the dynamic nature of the creation of subcollections.

I am not an expert engineer, but these were my experiences below that are a direct copy/paste from the Discord just for context. I am not trying to cause more work but rather pointing out that this work was already done and it would be a shame for a newer user to miss out on them.

Thank you again to everyone who has made this addon possible!

My Discord Ramblings Below:
grimberet : I cannot figure out how to query a sub collection. I don't see it in the docs, can anyone point me in the right direction?

grimberet: Okay, after digging through the code, I seem to have found where I can assign query().sub_collection_path = 'rootCollection/documentid123'
However I get an error if I do query.where('someNotEmptyField',FirestoreQuery.OPERATOR.NOT_EQUAL,''), because { "code": 400, "message": "collection group queries are only allowed at the root parent", "status": "INVALID_ARGUMENT" }

I'm not doing a group query am I? I am only querying one sub collection

grimberet : Okay, after printing my query to string I noticed the allDescendants that defaults to true. I switched that to false and it seems to have fixed everything. None of this was easy to find and I am super appreciative for the hard work, but this kind of stuff would be really helpful in the wiki

I can tell that a lot of hard work was done to make sure these options exist, so please let me know if I could help with adding these options to the wiki ... not sure I am experienced enough or what but I hate making recommendations if I am not willing to help out, which I am...

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

No branches or pull requests

1 participant