Skip to content
Advertisement

Firebase get doc ID that is nested several branches up

I am trying to search for all documents that contain a field, this field is contained in many documents. It’s a UID for users. I am trying to find all documents which contain a certain UID. Given the following struct:

projects > aa (or bb or cc etc many here) > projectTickets > someDocID (which contains the field).

So, I am trying to get the name of the first doc (aa for example). I am not sure how.So, I want to find all documents whose field value match the UID, and go up like 2 branches, and collect that name. Is this possible?

Advertisement

Answer

It’s hard to follow what you’re trying to do. But I can tell you that Firestore can only query a single collection at a time using specific named fields as a filter, or collection group queries against all collections with the same name. If you need to find data from multiple collections, you will need to perform multiple queries on those collections.

It’s not possible to query “all” documents in all collections, and it’s not possible to query data in collections where you don’t know the name of the field to filter on.

Advertisement