简体   繁体   English

如何检索自动生成的 ID 以删除 firebase 中的数据

[英]how do you retrieve a auto generated id to delete data in firebase

Im trying to delete this data in the app but im not sure how to retrieve the uid of the one i need to delete:我试图在应用程序中删除此数据,但我不确定如何检索我需要删除的数据的 uid:

so the first id is the current users id but how do i get the next unique id fo i can delete the records "test" and "Apple"所以第一个 id 是当前用户 id 但我如何获得下一个唯一 id 我可以删除记录“test”和“Apple”

this is how i upload the data to the database:这是我将数据上传到数据库的方式:

var currentUid = mAuth.currentUser?.uid
val myRef = database.getReference("Users")
val myRefCategory = myRef.child(currentUid!!).child("Following")


  fun sendDataToDatabase(category: String) {

    myRefCategory.push().setValue(category)

  }

how do i get the "MLt1lk1wtyvqLtQGZRF" and "MLt1bpUmJmAkjz_7tGN"?我如何获得“MLt1lk1wtyvqLtQGZRF”和“MLt1bpUmJmAkjz_7tGN”?

在此处输入图像描述

The key you're looking for is in the DatabaseReference returned by push() .您要查找的密钥在push()返回的DatabaseReference中。

val ref = myRefCategory.push()
val key = ref.key  // this is your key
ref.setValue(...)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在本地删除firebase中查询到的数据? - How do you delete queried data from firebase locally? 使用LiveData时如何从Room检索自动生成的ID? - How to retrieve auto generated ID from Room when using LiveData? 如何绕过唯一ID并检索多个自动生成的子代 - How to bypass unique ID and retrieve multiple auto generated child 如何尝试在RecyclerView中检索值我尝试了很多,但是在Android中将数据库中的数据推送到Firebase后,它从Firebase的ID中检索了空值 - How to Retrieve Value in RecyclerView I tried a lot but it Retrieve a Null Value from Generated ID by Firebase after Push Data in Database in Android 如何在单击ListView(由Firebase Data Elements创建)中检索项目的Firebase父ID? - How do I retrieve the Firebase parent id of an item in a ListView(created by Firebase Data Elements) is clicked? 使用自动生成的 ID 更新 firebase 中的文档 - Updating a document in firebase with an auto generated ID 如何使用 Kotlin 在 Android 中使用随机自动生成的 ID 检索 Firebase 节点的值 - How can i retrieve values of Firebase Nodes with random auto generated IDs in Android Using Kotlin 如何从 Firebase 实时数据库的推送方法中删除自动生成的项目 - how to delete the auto generated item from push method from Firebase Real-time database 您如何从电话号码中检索ID? - How do you retrieve an ID from a phone number? 如何更改firebase中的数据并检查id自动增量 - How to change data in firebase and check id auto increment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM