Reputation: 3122
I wanted to delete this record in firebase
, where i don't have the name of the key. so, I don't know how to do it. can anybody help me with this?
The code for getting array is as follows
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)
}
}
}
})
Upvotes: 0
Views: 2043
Reputation: 599
https://firebase.google.com/docs/database/ios/read-and-write
"The simplest way to delete data is to call removeValue on a reference to the location of that data."
Upvotes: 2