【问题标题】:Angular Firestore security rulesAngular Firestore 安全规则
【发布时间】:2020-04-09 09:28:51
【问题描述】:

我正在尝试查询以城市名称作为文档 ID 的城市名称集合,以及文档中名为“count”的单个字段,该字段由云函数递增。

但是,当我尝试查询这些数据时,Firebase 告诉我权限不足。

这是查询 Firestore 的代码

    db = firebase.firestore()
  async getCities() {
    var docRef = await this.db.collection("Cities").orderBy("count", "desc").limit(10)
      .get()
      .then(function(querySnapshot){
        querySnapshot.forEach(function(doc) {
          console.log(doc.id, " => ", doc.data());

        })
      })
      .catch(function(error) {
        console.log("Error getting documents: ", error);
    });

我有点困惑,因为规则游乐场表明应该允许此查询。

这是操场上允许我阅读的规则部分

match /Cities/{docId} {
  allow get;
}

还是因为我试图读取集合的子集?

【问题讨论】:

    标签: javascript google-cloud-firestore


    【解决方案1】:

    您需要将安全规则从 false 更改为 true,这就是我想将数据发布到 Firestore 数据库时发生的事情

    【讨论】:

      猜你喜欢
      • 2018-10-19
      • 2019-07-05
      • 2018-07-07
      • 2020-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-09
      • 1970-01-01
      相关资源
      最近更新 更多