I'm using firebase with java. I used to add data by
firebaseRef.child("users").push().setValue(user);
where my user
is object from User.class
with the following attributes
String name;
String id;
When I added validation to the data to accept input that has id equals to a secret key id === 'secret id'
as following
"user": {
".read": true,
".write": true,
".validate": "newData.hasChild('id')",
"id": {
".validate": "newData.val() === 'secret id'"
}
}
it shows me permission denied, I've tried many cases according to their documentation but I got the same permission denied.
Any suggestions?
Problem solved, Firebase.push() generates new id so newData
doesn't refer to it anymore, I made a variable to represent that id so that I can access my data normally
"user": {
"$key": {
".read": true,
".write": true,
".validate": "newData.hasChild('id')",
"id": {
".validate": "newData.val() === 'secret id'"
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.