在firebase中工作并首次设置复杂(对我而言)规则.
我有一个孩子的集合,其中有一个属性"parentId".我只希望某些角色和用户阅读此表.具体来说,我希望任何教练或裁判角色能够阅读以及任何孩子的父母.
我认为问题在于"data.child('parentId').val()=== auth.uid"在集合级.read.我觉得我完全按照这里的例子,但它仍然无效:https://www.firebase.com/docs/security/api/rule/data.html
谁能指出我在安全规则中做错了什么?
我知道安全规则不会过滤,我不相信这是特定问题的一个例子,因为我的查询特别将结果限制为我试图通过安全规则允许的内容(尽管我可能会弄错).
这是当前的安全规则.评论应该解释我的目标:
"children": {
// give ability of any coach or referee to read any child. Give refs ability to write to any child. Allow parent to query for their own children.
".read": "(data.child('parentId').val() === auth.uid) ||(root.child('users').child(auth.uid).child('role').val() === 'coach') || (root.child('users').child(auth.uid).child('role').val() === 'referee')",
".write": "root.child('users').child(auth.uid).child('role').val() === 'referee'",
".indexOn": ["parentId", "isApproved"],
"$child": {
// give a parent read and write access to only their specific children.
".read": "root.child('children').child($child).child('parentId').val() === auth.uid",
".write": "root.child('children').child($child).child('parentId').val() === …Run Code Online (Sandbox Code Playgroud) Sublime Text和Visual Studio中的等效行为是"Shift + Control + Return".我想找出一个解决方案.
要么我在文档中找不到这个,要么Webstorm中不存在这样的功能.
我怀疑可以创建一个宏来执行此操作,但我无法弄清楚如何在执行后使光标位置正确.
还有其他人为此找到了解决方案吗?