在我的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)
我尝试了很多东西,但无法弄清楚如何使这项工作发挥作用。
(我知道使用字符串而不是引用有效,但我更愿意使用引用)