我正在firebase中编写一个安全规则,以验证帖子是否存在或组是否存在。我完全理解安全规则不是过滤器,我不是将其用作过滤器,而是作为验证指标。这是我试图执行的规则。。。
"notifications": {
".read": "auth !== null",
".write": "auth !== null",
".indexOn": ["post_ID", "group_ID"],
"$userID": {
"$notifID": {
".validate": "newData.hasChildren(['has-seen', 'end-time', 'time', 'user_ID', 'username']) && $userID !== newData.child('sender_ID').val() && (root.child('groups').child(newData.child('group_ID').val()).exists() || root.child('follower-feed-storage').child(newData.child('post_ID').val()).exists())",
".write": "auth.uid !== $userID && !data.exists()",
}
}
},
显然,规则应该评估haschilds和$userID!==新建数据。子项('user\u ID')。val()条件正确。但是,何时应计算&之后的最后一个表达式&在括号内,它将根据括号内的第一个条件成功或失败,并且不执行or运算符并计算第二个表达式。很明显,我的语法有问题,但我无法理解。提前感谢您的帮助。