Say I have this minimal database stored in Cloud Firestore. How could I retrieve the names of subCollection1
and subCollection2
?
rootCollection {
aDocument: {
someField: { value: 1 },
anotherField: { value: 2 }
subCollection1: ...,
subCollection2: ...,
}
}
I would expect to be able to just read the ids off of aDocument
, but only the fields show up when I get()
the document.
rootRef.doc('aDocument').get()
.then(doc =>
// only logs [ "someField", "anotherField" ], no collections
console.log( Object.keys(doc.data()) )
)
It seems like they have added a method called
getCollections()
to Node.js:This example prints out all subcollections of the document at
/myCollection/myDocument
Isn't this detailed in the documentation?
In Node.js you'll be after the 'ListCollectionIds' method
This is not currently supported in the client SDKs (Web, iOS, Android).