Home > Blockchain >  Firestore - get collection Entries from document in collection
Firestore - get collection Entries from document in collection

Time:12-23

I would like to get the value which is red marked in the Screenshot below.

I tried a lot things also with google, but I do not came to a good result.

My code so far:

firestore.collection('chats').doc(this.uid).get().subscribe(data => {
      alert(data.data());
    });

Screenshot

CodePudding user response:

If what you circled in red is a collection, you will have to know the collection name, as you can't [get "all subcollections" of a document(https://stackoverflow.com/questions/48258632/fetching-all-collections-in-firestore/48258777#48258777) in the client-side SDKs.

So you'll need to know the name of the collection already. Once you do, accessing it is:

firestore
  .collection('chats')
  .doc(this.uid)
  .collection("the subcollection name")
  .get()
  • Related