Google cloud firestore 将通配符变量传递到path的Firestore安全规则
我有以下安全规则:Google cloud firestore 将通配符变量传递到path的Firestore安全规则,google-cloud-firestore,firebase-security,Google Cloud Firestore,Firebase Security,我有以下安全规则: match /collection1/{doc_id} { allow read: if (get(/databases/$(database)/documents/collection2/$(doc_id)).author == request.auth.uid); } 我正在做的是尝试将通配符变量从父路径doc\u id传递到get方法的路径中。此文档在collection1中的读取权限取决于另一个集合c
match /collection1/{doc_id} {
allow read: if (get(/databases/$(database)/documents/collection2/$(doc_id)).author ==
request.auth.uid);
}
我正在做的是尝试将通配符变量从父路径doc\u id
传递到get
方法的路径中。此文档在collection1
中的读取权限取决于另一个集合collection2
中具有相同id的文档的author
字段。我不相信我将doc\u id
作为$(doc\u id)
传递的方式是正确的,因为我得到一个错误:属性作者在对象上未定义
我也试过
(doc\u id)
和\doc\u id
,但它们的语法错误。那么,如何将通配符变量传递到路径?其中缺少一个数据,这是获取文档字段所需的:
get(/databases/$(database)/documents/collection2/$(doc_id)).data.author
啊,get(path)返回rules.firestore.Resource
我忘记了data
。谢谢你,弗兰克