firebase - 检查项目是否存在于 Firebase 安全规则的子集合中
问题描述
我在使用 firebase 安全规则模拟器时遇到问题,我无法读取字段是否存在。我的结构如下,其中 meta 是团队的子集合,每个团队都在团队集合中。
{
"teams": {
<TEAM_ID>" {
"name": "Team One"
"meta": {
"users": [<SOME USER UID>],
"admins": [<SOME UID>]
}
}
}
}
基本上,我只希望他们能够读取 meta.users 中是否有用户 ID。
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /teams/{teamId} {
allow read: if exists(/databases/$(database)/documents/teams/$(teamId)/meta/users/$(request.auth.uid))
}
}
}
但上述规则返回以下错误。
运行模拟时出错 - 错误:simulator.rules 行 [5]、列 [21]。找不到函数错误:名称:[存在]。
解决方案
推荐阅读
- javascript - Chrome 的 Ctrl+F 是如何实际应用搜索高亮的?
- docker - 扩展 Dockerfile nginx 镜像
- postgresql - 尽管存在,但 postgis 扩展安装无法找到文件
- java - JPA 实体的 UUID 主键:在多个实例上使用唯一值的安全方法
- jpa - 如何使用 JPA OneToMany 关系一次更新多个对象?
- c - 错误:变量“v1”具有初始化程序但类型不完整
- swift - 将参数传递给 SwiftUI 工作表
- python - Python:包和编译器有什么区别?
- typescript - TypeScript 版本警告,TypeScript xx 功能当前语言级别为 xx,在 Visual Studio 2019 中
- javascript - Javascript:提交后避免刷新页面