I tried doing db.collection("posts").collection("comments").get()
and db.collection("posts/comments").get()
but neither seemed to work.
CodePudding user response:
Subcollections live under a specific document. In order to access the comments
subcollection of a specific post, you'll need to specify that post ID in the path:
db.collection("posts").doc("post ID you want").collection("comments").get()
If you want to access documents across all comments
collections, you'll want to use a collection group query:
db.collectionGroup("comments").get()