博客类应用程序的Firebase安全规则
我只是在玩firebase,存储用户博客帖子,计算喜欢和不喜欢的内容 我把邮件存放在下面博客类应用程序的Firebase安全规则,firebase,firebase-realtime-database,firebase-security,Firebase,Firebase Realtime Database,Firebase Security,我只是在玩firebase,存储用户博客帖子,计算喜欢和不喜欢的内容 我把邮件存放在下面 /posts/$uid/$key (例如:/posts/xfsdfsfsdf/-KKm1gBQRivx1x-thh8m) 为了查询所有帖子,我还将相同的数据存储在/timeline/$key (例如:/timeline/-KKm1gBQRivx1x-thh8m) 类似于喜欢和不喜欢,我的安全规则是这样的 { "rules": { ".read": true, "posts":{
/posts/$uid/$key
(例如:/posts/xfsdfsfsdf/-KKm1gBQRivx1x-thh8m
)
为了查询所有帖子,我还将相同的数据存储在/timeline/$key
(例如:/timeline/-KKm1gBQRivx1x-thh8m
)
类似于喜欢和不喜欢,我的安全规则是这样的
{
"rules": {
".read": true,
"posts":{
"$uid":{
".write": "$uid === auth.uid"
}
},
"timeline":{
"$key":{
".validate": "root.child('posts/'+ auth.uid +'/'+$key).exists()",
".write": "auth != null"
}
},
"user-likes": {
"$uid":{
"$post":{
".write": "$uid === auth.uid",
".validate":"root.child('timeline/'+$post).exists() && newData.child('type').exists()"
}
}
},
"likes": {
"$post":{
"$key":{
".validate": "root.child('user-likes/'+ auth.uid +'/'+$post+'/'+$key+'/ type').val()==newData.child('type').val()",
".write": "auth != null",
".indexOn": ["type"]
}
}
}
}
}
两次保存数据是否有问题?有没有其他更好的解决办法