防止在firebase引用中删除和更新子项

时间:2017-11-10 14:49:00

标签: javascript firebase firebase-realtime-database firebase-security

我正在开发一个将数据存储在firebase数据库中的项目,如下所示:

{
    "child_name": "string",
    "child_name2": "another string"
}

我正在努力确保人们可以阅读和编写新的孩子,但不能编辑或删除它们。 我尝试使用规则".write": "!data.exists()"来阻止人们删除或更新,但相反,它似乎会阻止所有请求 - 即使数据正在添加新的孩子。

我用来添加孩子的代码是这样的:

var ref = firebase.database().ref();
ref.child(newChild).set(input.value); /*newChild is a string determined by 
reading the list of children already existing and creating a string that is unique*/

我想知道我是否使用了错误的规则或不正确的添加数据的方法,以及是否有允许人们添加新子项但不删除或更新的规则。

0 个答案:

没有答案
相关问题