如何限制用户推送数据或向firebase数据库子项添加多个子项

时间:2017-03-24 14:35:14

标签: javascript json security firebase rules

在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",
    }   
  },
 }

}

1 个答案:

答案 0 :(得分:0)

您可以在节点中添加布尔值,然后就可以像".write": "root.child('node_name').child('can_write').val() === true

那样进行测试