繁体   English   中英

如何在 Firestore 的文档中获取 collections

[英]How to get the collections inside a document in firestore

我正在尝试获取文档中的所有 collections,但出现错误。

我正在这样做:

this.db = firebase.firestore();

this.db.collection("RestaurantMenus").doc(this.restaurant.key).listCollections().then((querySnapshot) => {
      querySnapshot.forEach((collection) => {
        console.log("collection: " + collection.id);
      });

它说 listCollections() 不是 function。 我试过 getAllCollections() 它说的一样。 我试图从文档中获取数据,但只获取数据而不是 collections。

我不知道还能做什么。我做错了什么?

我的火库:

集合--->“RestaurantMenus”----> doc: this.restaurant.key ----> 我想要的集合

您尝试调用的 API 仅在 Firestore 的服务器端 SDK 中可用。 没有 API 可以使用 Firestore 的客户端SDK 获取 collections 的列表。

出于这个原因,您通常希望使用固定名称(如“RestaurantMenus”)作为您的集合 ID,并且只将生成的 ID 用于文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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