Reputation: 23
I am trying to restrict editing the "version" child in my database, but somehow rules are not working. Here is my code in rules:
{
"rules": {
".read": true,
".write": true,
"version": {
".write": false
}
}
}
In rules playground, it somehow skips the rule defined for specific child and reads rule for global.
Upvotes: 1
Views: 102
Reputation: 512
What is happening here you defined rules for parent (globally) as true and you are trying to limit the access at its child level (locally) so by default it will take attributes of parent for access. Instead what you can do is if you want to allow access for reading for all childs and limit the write access to specific child you can define rules like this
{
"rules": {
".read": true,
"version": {
".write": false
}
}
}
so if you add any more childs and want to give them some special access
{
"rules": {
".read": true,
"version": {
".write": false
},
"data": {
".write": true
}
}
}
lets say you want to limit the read access of second child so instead of defining rules globally you will define them for each child
{
"rules": {
"version": {
".read": true,
".write": false
},
"data": {
".read": false,
".write": true
}
}
}
Upvotes: 2