I want to filter a query collection on a reference field. I did get the query to run without an error after an hour of trying. But the query returns zero rows where I know there are several matches.
I want to run a Firebase query and filter on a (foreign-key) reference field. It looks like the REST API is being used in the background as it only runs when I use this syntax for the reference field on which I want to filter:
projects/{my-project}/databases/(my-database}/documents/{my-document}/{document-id} although I’m not sure because this returns zero results.
What is the correct syntax here? Or is there a bug or ommision in the query functionality?
Foud it!
Use (default) for the database value:
projects/{my-project}/databases/(default)/documents/{my-document}/{document-id}
This would be so much simpler when there was some more comprehensive documentation.
1 Like
Heya @based75
Awesome that you managed to figure this out and thanks a lot for sharing what you learned with the community!
I’m really sorry that you felt that our documentation didn’t quite hit the mark in addressing this matter. I’m sure that what I’ll share here is what you eventually found but in case anyone is looking for this in the future:
In our help doc for Google Cloud Firestore, there is a dedicated section on Queries that includes an example of a Document Path. You’ll also find a handy link within that section, leading to Google’s documentation where you can explore a comprehensive list of field operators.