[英]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.