简体   繁体   English

firebase 从实时数据库中删除特定项目

[英]firebase delete specific item from Realtime Database

在此处输入图像描述 don't know how to make user abele to delete his own comment in android studio using java不知道如何让用户能够使用 java 在 android 工作室中删除自己的评论

all comments played at list列表中播放的所有评论

need user to press button delete to delete his comment需要用户按下删除按钮来删除他的评论

and no one can delete comment not his没有人可以删除不是他的评论

[![this is my data structure] [![这是我的数据结构] 在此处输入图像描述

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.

相关问题 如何从firebase实时数据库中删除选中的item节点? - How to delete selected item node from firebase realtime database? 如何删除Firebase实时数据库中的特定数据? - How to delete a specific data in Firebase Realtime Database? 显示 firebase 实时数据库中的单个项目的回收视图 - Recycle view showing single item from firebase realtime database 从 Node.js 中的 Firebase 实时数据库中选择特定属性 - Select specific properties from Firebase Realtime Database in Node.js 如何删除firebase实时数据库中的一个节点javascript - How to delete a node in firebase realtime database in javascript 将 firebase 身份验证与来自 firebase 的实时数据库连接 - connect firebase authentication with realtime database from firebase 在实时数据库中检索特定值 - Firebase - Retrieve specific values in a Realtime Database - Firebase 如何在 React Native 中从我的实时 Firebase 数据库中删除单个条目? - How to delete a single entry from my Realtime Firebase database in React Native? 如何从firebase实时数据库中获取数据 - How to retrieve data from firebase realtime database 如何使用查询或特定路径从 Firebase 实时数据库中高效查询 - How to efficiently query from Firebase Realtime Database using query or specific path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM