如何限制用户向 firebase 数据库 child 推送数据或添加 child 个以上
How to restrict users to push data or adding child more than one to firebase database child
在firebase安全规则中,我们如何限制用户向数据库推送多个数据?
我一直在尝试这个但没有成功
{
"rules": {
".read": false,
".write": false,
"voters": {
// restrict user to adding child more than one in this path
// one user only alowed to add one child
".read": true,
".write": "auth !== null",
".validate": "newData < 2",
"$votersuid": {
".read": true,
".write": "auth.uid == $votersuid",
}
},
}
}
您可以向您的节点添加一个布尔值,然后您可以像这样进行测试".write": "root.child('node_name').child('can_write').val() === true
在firebase安全规则中,我们如何限制用户向数据库推送多个数据?
我一直在尝试这个但没有成功
{
"rules": {
".read": false,
".write": false,
"voters": {
// restrict user to adding child more than one in this path
// one user only alowed to add one child
".read": true,
".write": "auth !== null",
".validate": "newData < 2",
"$votersuid": {
".read": true,
".write": "auth.uid == $votersuid",
}
},
}
}
您可以向您的节点添加一个布尔值,然后您可以像这样进行测试".write": "root.child('node_name').child('can_write').val() === true