我想在 firebase
中删除这条记录,但我没有 key 的名称。所以,我不知道该怎么做。有人可以帮我吗?
获取数组的代码如下
var databaseRefer : DatabaseReference!
let userID = Auth.auth().currentUser?.uid
databaseRefer = Database.database().reference(withPath: userID!)
databaseRefer.observeSingleEvent(of: .value, with: { snapshot in
if !snapshot.exists() { return }
if snapshot.value is NSNull {
print("not found")
} else {
for child in snapshot.children {
let snap = child as! DataSnapshot
print(dict)
dict.forEach { item in
print(item.value)
}
}
}
})
最佳答案
https://firebase.google.com/docs/database/ios/read-and-write
“删除数据的最简单方法是在对该数据位置的引用上调用 removeValue。”
关于ios - 如何在 swift 中从 firebase 中删除子记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51632680/