I want to
is there a way to do this? Can anyone help me ?
Unfortunately i cannot make it work. I have only succeed to the part to check the old value and the new value. This works But ONLY this if the user is ALREADY registered in the database.
I also tried to add the !data.exists but it is not working .
Below my rules
{
"rules": {
".read": true,
"Users" : {
"3X3": {
"$userID": {
".write": "data.child('time').val() > newData.child('time').val()"
}
}
}
}
}
I think you're looking for:
{
"rules": {
".read": true,
"Users" : {
"3X3": {
"$userID": {
".write": "
!data.exists() || // 👈
data.child('time').val() > newData.child('time').val()
"
}
}
}
}
}
Also see the Firebase documentation on new vs existing data in security rules.