简体   繁体   中英

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);
  });

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 (eg an array) in the document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM