Reputation: 224
I have a firebase structure of something along this line -
root {
groups {
gid: { //group ID
authid: ... //group creator's uid
members: { //uid of members
...
}
posts: {
... //posts ID
}
}
}
}
I want these features -
".write":"(!data.exists() && auth.uid != null) || (data.exists() && newData.exists()"
A single group can be deleted by only the author. This means I need to give the permission to set null to the individual group nodes to the authors. This is the part where I'm stuck. Because, shallower rules override deeper rules. So, if I just write
"groups": { "$gid": { ".write":"!newData.exists() && data.child('authid').val() === auth.uid" } }
this will be plain ignored.
I don't want anyone, even the author to set null to the individual nodes inside a group. Which means the author can delete a whole group, but not, say, the members node
Upvotes: 1
Views: 1838
Reputation: 598728
Right now you're requiring that there is no data after the write operation.
What you want is that either no data
".write": "
(data.exists() && !newData.exists() && data.child('authid').val() === auth.uid)
|| (data.exists() && newData.exists() && data.child('members').child(auth.uid).exists())
|| (!data.exists() && newData.child('authid').val() === auth.uid)
"
Line:
Upvotes: 2