How to write a rule to prevent the removal of a node from the database

I am trying to write rules to protect the database. But I am confused by writing a rule that will prevent the removal of any node from the database. I read about newData.exists, but when I tried to run it in the simulator, the deletion was done! How can a node be deleted by setting its value to zero, so I tried to simulate the value of node equal to null, and it was successful, which is undesirable.

Suppose I have this node:

root{
Number of Users:20
}

And I wrote these rules:

"Number of Users":{
".read":true,
 ".write":"auth!==null && newData.exists()"
 }

I'm making any mistake, please correct me.

+4
source share
1 answer

, node:

".write": "!data.exists()"

, , node:

".write": "newData.exists()"

: Unable to write null

+10

Source: https://habr.com/ru/post/1668174/


All Articles