Ujj*_*dha 6 firebase firebase-security google-cloud-firestore
在 firebase firestore 安全规则中,我只想在特定文档不存在时才允许请求。我的代码是:
match /users/{user_id} {
allow create: if !exists(/databases/$(database)/merchants/$(request.auth.uid));
}
Run Code Online (Sandbox Code Playgroud)
我很确定该文件不存在,但它不起作用。双方exists()并!exists()提供虚假不知何故,也许!exists()带来了一些错误。
我什至尝试过:
match /users/{user_id} {
allow create: if exists(/databases/$(database)/merchants/$(request.auth.uid)) == false;
}
Run Code Online (Sandbox Code Playgroud)
有什么办法可以使这项工作?
您的规则是否在数据库块内?因为我有一个类似的问题,实际上是把规则放在数据库块下面,我的规则$(database)和你的一样使用参数
service cloud.firestore {
match /databases/{database}/documents {
match /users/{user_id} {
allow create: if !exists(/databases/$(database)/merchants/$(request.auth.uid));
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2511 次 |
| 最近记录: |