So as of May 8 2019, Firebase Firestore now supports querying sub-collections of the same name via collectionGroup('collectionName')
.
Is there a way to retrieve multiple documents of the same docId
across these sub-collections?
Here's a little visual example of what I'm trying to accomplish.
collectionA
- documentA
: collectionB
- documentC
- documentB
: collectionB
- documentC
Let's say I want to get both of those documentC
documents. Is there a way to do so?
The current code I'm trying, to use is this:
const docIdFieldPath = FieldPath.documentId()
admin.firestore().collectionGroup('collectionB').where(docIdFieldPath, '==', 'documentC').get().then(...)
However I'm thrown an error of:
INVALID_ARGUMENT: Resource name "projects/myProject/databases/(default)/documents/documentB" lacks "/" at index 86.
The docs on the matter say to create an index before attempting querying via collectionGroup
, but if I try to do so via the online-index-portal I get an error saying that the __name__
field is reserved.
Am I missing something silly, or is this feature not supported yet?