Angular Firestore安全规则

时间:2020-04-09 01:25:37

标签: javascript google-cloud-firestore

我正在尝试查询以城市名称作为文档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;
}

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

1 个答案:

答案 0 :(得分:0)

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