I have the following Firebase database rules, but this only allows data to be written once. Nothing after that.
Edit. I want to make sure no data ever gets deleted, also.
{
"rules": {
"$uid": { //userIDTom
".read": "true",
".write": "!data.exists()"
}
}
}
I want to be able to write a child only if that child does not exist.
Example,
"userIDTom" : {
"testKey1" : "test1",
"testKey2" : "test2",
"testkey3" : "test3"
}
}
}
All the above will be written into "UserIDTom"
But in the next example,
"userIDTom" : {
"testKey4" : "test4",
"testKey2" : "update",
"testkey5" : "test5"
}
}
}
In the above example, only testKey4 and testKey5 will be written. testKey2 will be skipped because it already exists. Note it should still be skipped even if it's value is different. In other words, only allow writing of new keys.
End result should be:
"userIDTom" : {
"testKey1" : "test1",
"testKey2" : "test2",
"testkey3" : "test3",
"testKey4" : "test4",
"testkey5" : "test5"
}
}
}
}
}