【问题标题】:Firestore security rules: is it possible to chain get() and exists()Firestore 安全规则:是否可以链接 get() 和 exists()
【发布时间】:2018-10-17 10:35:36
【问题描述】:

Firestore 安全规则:有没有办法“链接”一个 get 和一个 exists ? 我想调用exists(),但我需要先get() docID。就像是: exists(/databases/$(database)/documents/Collection2/ ** 这里我应该做一个 get(/...) 来获取所需的 docID **);

我试图在一行中完成所有功能,2 个功能,......我无法让任何东西工作。

function f1(entryParam) {
  return get(/..).data.myDocId;
}

function f2(docID) {
  returns exists(/databases/$(database)/documents/collection2/$(docID));
}

然后:

match /col3/{doc3ID} {
  allow xx: if f2(f1(doc3ID));
}

我尝试过的都没有奏效。 我真的必须“手动”获得所需的数据,即在一个查询距离内吗?

提前感谢您的帮助/回答。 菲利普

【问题讨论】:

    标签: google-cloud-firestore


    【解决方案1】:

    我找到了解决方案(RTFM!) 诀窍是使用路径对象: rules.Path documentation

    【讨论】:

      猜你喜欢
      • 2020-08-22
      • 2019-12-14
      • 1970-01-01
      • 1970-01-01
      • 2018-03-19
      • 2021-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多