以编程方式查找 Firestore 文档的所有子集合



有没有办法在不明确知道其名称的情况下以编程方式访问文档中的子集合? 我本质上正在寻找一个类似于firestore((.getCollections((的函数,但用于文档而不是数据库的根目录。

db
  .collection("collection")
  .doc("document")
  .get()
  .then(doc => {
    if (doc.exists) {
      doc.getCollections().then(collections => {
        //do stuff
      });
    }
  })
//...

显然docSnapshots没有这个功能,但是还有其他方法可以实现吗? 还是您必须提前知道子集合的名称?

我是个白痴。

db
  .collection("collection")
  .doc("document")
  .getCollections()
  .then(collections => {
      //do stuff
  });

最新更新