Using post method, data is posted like below. Every node has some unique ID. So how can I prevent duplicate data from posting into this JSON data model using rules in firebase?
REST POST URL: https://*****.firebaseio.com/user_details.json
{
"-Ktzg49_ArPtNZ9SDpIw": {
"email": "amee11315@gmail.com",
"name": "Abir Hossain Amee",
"profile_photo": "https:\/\/graph.facebook.com\/1928067980740489\/picture?type=large"
},
"-KtzpFMjjcvN7Mooh-4I": {
"email": "arshohag7@gmail.com",
"name": "Ashiqur Rahman",
"profile_photo": "https:\/\/graph.facebook.com\/1570862736318692\/picture?type=large"
},
"-KtzpbLGDRBo9dH3uZSZ": {
"email": "arshohag7@gmail.com",
"name": "Ashiqur Rahman",
"profile_photo": "https:\/\/graph.facebook.com\/1570862736318692\/picture?type=large"
},
"-Ktzq3HgVp9ykErVXg_8": {
"email": "arshohag7@gmail.com",
"name": "Ashiqur Rahman",
"profile_photo": "https:\/\/graph.facebook.com\/1570862736318692\/picture?type=large"
}
}
I tried these rules
{
"rules": {
".read": "true",
".write": "true",
"user_details" : {
"$email" : {
".write": "!data.exists()"
}
}
}
}
But can't stop duplication or achieve normalization.