小编Yan*_*Yan的帖子

Firestore 规则比较对构造路径的引用

在我的company文档中,我有一个名为 的引用字段owner,它指向一个user文档。在规则中,我试图检查经过身份验证的 uid 是否是公司的所有者:

match /companies/{companyId} {
  allow read: if isOwner(resource.data.owner, request.auth.uid);
}



function isOwner(owner, userId) {
   return path('/users/' + userId) == owner;
}
Run Code Online (Sandbox Code Playgroud)

我尝试了很多东西,但无法弄清楚如何使这项工作发挥作用。

(我知道使用字符串而不是引用有效,但我更愿意使用引用)

firebase google-cloud-firestore

3
推荐指数
1
解决办法
660
查看次数

标签 统计

firebase ×1

google-cloud-firestore ×1