[英]firebase delete specific item from Realtime Database
Solution1: Add a user's uid in the comment.解决方案1:在评论中添加用户的uid。 Use that uid to match the current logged-in user's uid to show delete button in your UI.
使用该 uid 来匹配当前登录用户的 uid 以在您的 UI 中显示删除按钮。 data structure for comments: [{uid, name, photoUrl, rating, text}]
评论的数据结构:[{uid, name, photoUrl, rating, text}]
Solution2: The above way should work but essentially all users had delete access to anyone's comment.. it's just that you're not showing the mechanism in UI.解决方案 2:上述方法应该可行,但基本上所有用户都可以删除任何人的评论。只是你没有在 UI 中显示该机制。 for better security I guess you should look at https://firebase.google.com/docs/database/security something like should work
为了更好的安全性,我想你应该看看https://firebase.google.com/docs/database/security类似的东西应该可以工作
{
"rules": {
"items": {
"$item_id" : {
"comments": {
"$comment_id": {
".read": "auth != null",
".write": "auth != null && (data.child('uid').exists() ? (data.child('uid').val() == auth.uid) : true)"
}
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.