文档:https://www.firebase.com/docs/javascript/firebase/setpriority.html
有没有遗漏什么重要的东西?
我正在尝试通过某个身份验证用户更新组的优先级。只有当我被认证为组的所有者时,我才能这样做,并且我不知道为什么以及如何像我对"membersCount“所做的那样,只为更新优先级的所有身份验证用户授予访问权限。
// GROUPS
"groups": {
"$subCategoryId": {
"$groupId": {
// ONLY OWNER OF GROUP CAN UPDATE THE userId, name, hashTag, categoryId
//
// The first init has to have userId, name, categoryId
//
// Anyone can update the membersCount
".write": "newData.hasChildren(['userId','name','categoryId']) || !data.exists() || auth != null",
"userId": {
".validate": "auth.uid == newData.val()"
},
"name": {
".validate": "newData.val() != '' && newData.val().length < 30 && (data.parent().child('userId').val() == auth.uid || !data.parent().child('userId').exists())"
},
"hashTag": {
".validate": "(data.parent().child('userId').val() == auth.uid || !data.parent().child('userId').exists())"
},
"categoryId": {
".validate": "newData.val() != '' && root.child('categories').child(newData.val()).exists() && root.child('subcategories').child(newData.val()).child($subCategoryId).exists() && (data.parent().child('userId').val() == auth.uid || !data.parent().child('userId').exists())"
},
"membersCount": {
".write": "auth != null && newData.isNumber() && (data.val()+1 == newData.val() || data.val()-1 == newData.val() )"
}
}
}
},当我尝试更新({ '.priority':2})时,我得到:
未捕获的错误: update()当前不支持更新.priority。
发布于 2014-04-10 01:47:46
在这种情况下,错误消息与安全规则无关。不能使用update()命令更新优先级。您可以使用setPriority(2)来完成此操作。
如果您想在安全规则中引用优先级,可以使用getPriority来实现。
https://stackoverflow.com/questions/22884063
复制相似问题