Str*_*ere 6 angularjs firebase
如何在firebase规则中检查数组中的值.我想做这样的事情:
root.child('connections/'+auth.uid).child('friends').child(someFriendId).exists()
Run Code Online (Sandbox Code Playgroud)
因此,在当前用户的连接节点下,如果在friends数组中存在someFriendId,则允许访问.'someFriendId'不是friends数组的键,也就是使用firebase push()方法生成的自动ID.
通常,避免分布式数据中的数组,并在结构化数据指南中阅读Firebase中的数组.
您无法在Firebase安全规则中执行"包含".相反,您需要将用户存储为密钥,类似于我们在安全文档中演示此用例的方式.
因此,给出您的示例,唯一的更改是使用用户ID替换数组索引,并将值更改为布尔值(或任何其他有用的值).然后您的安全规则可以构造为:
root.child('connections/'+auth.uid+'/friends/'+someFriendId).exists();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5834 次 |
| 最近记录: |