【问题标题】:Get all collections name from firebase database从 firebase 数据库中获取所有集合名称
【发布时间】:2021-05-27 05:01:47
【问题描述】:

我想知道使用js的firebase数据库的所有集合名称,但仍然没有得到任何解决方案。

我试过了

db.collection().get().then(()=>{})

但它给了我一个错误,必须在集合中写集合名称

【问题讨论】:

  • 这能回答你的问题吗? Fetching all collections in Firestore
  • 您可能对以下article 感兴趣,它提供了一种解决方案,可以列出 Cloud Firestore 文档的所有子集合或列出 Cloud Firestore 数据库的所有根集合。

标签: firebase firebase-realtime-database google-cloud-firestore firebase-authentication


【解决方案1】:

Admin API 可以让你做到这一点

const admin =  require(firebase-admin);
const db = admin.firestore();

db.listCollections()
...

查看这个帖子了解更多详情: Fetching all collections in Firestore

【讨论】:

    猜你喜欢
    • 2012-12-27
    • 1970-01-01
    • 2011-01-18
    • 2019-10-06
    相关资源
    最近更新 更多