[英]firebase delete specific item from Realtime Database
解决方案1:在评论中添加用户的uid。 使用该 uid 来匹配当前登录用户的 uid 以在您的 UI 中显示删除按钮。 评论的数据结构:[{uid, name, photoUrl, rating, text}]
解决方案 2:上述方法应该可行,但基本上所有用户都可以删除任何人的评论。只是你没有在 UI 中显示该机制。 为了更好的安全性,我想你应该看看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.