Reputation: 4281
I am trying to remove a value within the Firebase Realtime Database. Here is the code I am using:
FIRDatabase.database().reference()
.child(FIRAuth.auth()!.currentUser!.uid).child("instagramLink")
.removeValue()
Here is the JSON Data Structure:
Users {
userUID {
email: "test@test.com"
fullName: "John Doe"
instagramLink: "testLink"
}
}
I am telling the database to remove the key "instagramLink", which I know is currently in the database, but the key never gets removed.
How do I remove the key?
Upvotes: 3
Views: 8470
Reputation: 9955
Extending to @cartant's answer , this way you will know if you run along any error during removal or if the value's were removed successfully or not.:)
FIRDatabase.database().reference().child(Users).child(FIRAuth.auth()!.currentUser!.uid).child("instagramLink").removeValueWithCompletionBlock({ (error, refer) in
if error != nil {
print(error)
} else {
print(refer)
print("Child Removed Correctly")
}
Upvotes: 10
Reputation: 58430
It looks like you've left Users
out of the path:
FIRDatabase.database()
.child("Users")
.child(FIRAuth.auth()!.currentUser!.uid)
.child("instagramLink")
.removeValue()
Upvotes: 7