google-cloud-firestore - 嵌套的 Firestore 安全规则 - get()
问题描述
有谁知道我是否可以创建嵌套的“获取”规则来访问数据库中的不同数据?如何?
// Assignment's document
match /assignments/{assignmentId} {
function getAssignmentOwner(){
return get(/databases/$(database)/documents/assignments/$(assignmentId)).data.owner;
}
function getAgencySupervisors(){
return get(/databases/$(database)/documents/agencies/$(getAssignmentOwner())).data.supervisors;
}
allow write: if request.auth.uid in getAgencySupervisors();
allow read: if request.auth != null;
}
目前它返回“不允许”。
解决方案
规则不是数据过滤器;您应该只对集合、文档或子集合使用规则,您不能使用规则来过滤文档内的结果。
文档:https ://firebase.google.com/docs/firestore/security/rules-structure
推荐阅读
- android - Android 测试 - 更改系统值以测试逻辑分支
- redis - 系统设计近乎实时地聚合过去五分钟、最后一小时和最后一天分享次数最多的 N 篇文章?
- django - 如何在 Django 中创建引用两个相关模型的注释
- node.js - node.js/express:将 router.route() 与中间件功能一起使用
- google-sheets - 如何根据通过 Google 表单响应添加的数据中的两个标准将数据拉入单独的选项卡
- r - 重新建立抓取网页 pdf 的列的提示
- django - 'render' 对象没有属性 'GET'
- reactjs - 映射数组以生成 React 组件时,不遵守数组顺序
- go - 在 Golang 中查询 DynamoDB 上的二级索引
- python - 如何将 ICD9 代码识别为虚拟变量?