I'm experimenting with Firebase
and curious about the security rules.
Let's say you have a firebase data set represented as simply as:
{
"myNewData" : "Some String"
}
How could you write a rule so that only an object that gets written has the key name myNewData
?
I'm using the POST
method and the data is structured in Firebase as follows:
-myFireBaseapp
-someData
-RandomFirebaseKey
-myNewData
-RandomFirebaseKey
-myNewData
in the simulator I came up with
{
"rules": {
".read":true,
"$someData":{
".write":true,
".validate": "newData.hasChild('myNewData')"
}
}
}
which works in the simulator but not in postman.
POST
http://myfirebase.app.bucket/someData.json
{
"myNewData" : "Some String"
}
Thanks for any info.
myNewData
is a key of a value. I'll write up an answer that I hope is helpful. – Frank van Puffelen