Reputation: 254
I am trying to delete an object with multiple children in my Firebase database. My data is setup like so:
I am running the following code in my iOS app:
[[ref child:[NSString stringWithFormat:@"/playlistSongs/%@", playlistObject[@"firebaseID"], nil]] removeValueWithCompletionBlock:^(NSError * _Nullable error, FIRDatabaseReference * _Nonnull ref) {
if (error) {
NSLog(@"ERROR: %@", error.localizedDescription);
} else {
NSLog(@"DELETED!");
}
}];
When this code runs, DELETED! is outputted in the log. However the object still remains in my firebase database. Is it possible to delete objects with multiple children? Looking at the documentation here, it suggests that I should be able to do so. It would be great if someone could point me in the right direction.
Upvotes: 0
Views: 2522
Reputation: 51
remove value function is work for me
[[[_ref child:@"playlistSongs"] child:snapshot.key] removeValue];
Upvotes: 1
Reputation: 35677
Sometimes simpler is better:
Firebase *ref = path to the parent node
[ref setValue: nil];
Upvotes: 3
Reputation: 363
It should be better if you stand "playlistSongs" and call updateChildValues with nil param.
Upvotes: 0