How to access sub collection in angular and firestore

I am trying to access a sub-collection inside a document using cloud firestore in angular but it isn't showing the sub-collections and only shows fields and its values

Here is the code. I want to get subCollection names.

this.afs.collection(`users/${this.user.uid}/Root`).doc('Folder').valueChanges().subscribe(item => {
    console.log(item);
  });

1 answer

  • answered 2018-11-08 08:13 Renaud Tarnec

    At the time of writing, the only libraries/SDKs that allow listing the sub-collections of a document are the ones that are used in "trusted server environments" like the ones for Node.js, Java, PHP, etc., see the doc about this: https://firebase.google.com/docs/firestore/query-data/get-data#list_subcollections_of_a_document.

    Retrieving a list of collections is not possible with the mobile/web client libraries

    A workaround is to store the sub-collection name(s) in a field (e.g. an array) in the document.