Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get removed item's key from child_removed firebase event

Tags:

firebase

Is it possible to retrieve the key of the removed child's key in Firbase's on('child_removed') callback function?

like image 916
Sebastian Sandqvist Avatar asked Dec 25 '22 10:12

Sebastian Sandqvist


1 Answers

From the Firebase documentation for on('child_removed':

This event will be triggered once every time a child is removed. The DataSnapshot passed into the callback will be the old data for the child that was removed.

firebaseRef.on('child_removed', function(oldChildSnapshot) {
  console.log('Child '+oldChildSnapshot.key()+' was removed');
});
like image 53
Frank van Puffelen Avatar answered Dec 28 '22 11:12

Frank van Puffelen