Reputation: 162
So I have this structure:
collection(users) { document(unknownID){ collection(listings) }, document(anotherUnknownId){ collection(listings) }, }
There will be many documents with unknownID how I should get those listings inside document with unknownID ?
const collectionRef = firestore().collection('users').doc(unknownID).collection('listings');
What to do with that unknownID, how to get every listings collection inside ?
Upvotes: 0
Views: 1183
Reputation: 317467
If you don't know the full path of the collection to query, then you won't be able to query it.
There are no workarounds: you will have to store the path somewhere so that your code can query it, or organize your data differently so that there are no unknowns when it comes time to query.
Upvotes: 2
Reputation: 5841
As documentation specifies:
When you delete a document, Cloud Firestore does not automatically delete the documents within its subcollections. You can still access the subcollection documents by reference.
Now since the document ids are auto-generated, you will need to have some mechanism to remember and identify those records. Following are the workarounds popping up in my head:
isPermanantlyDeleted:true
. This way you will be able to query only deleted documents.Upvotes: 1