使用post方法,数据发布如下。每个节点都有一些独特的 ID。那么如何使用firebase中的规则防止重复数据发布到此JSON数据模型?
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"
}
}
我试过这些规则
{
"rules": {
".read": "true",
".write": "true",
"user_details" : {
"$email" : {
".write": "!data.exists()"
}
}
}
}
但无法阻止重复或实现规范化。