According to the documentation, the DataSnapshot
received in the child_removed
callback contains the old data for the removed child.
I have a scenario where I am adding data using push
and then trying to access the next value after the top child is removed from my database. Here is what I have attempted so far:
var ref = firebase.database().ref("Windsor boyss").limitToFirst(1);
ref.on("child_removed", function(snapshot) {
ref.once("value", function(snapshot) {
snapshot.forEach(function(childSnapshot) {
console.log("Child is ", childSnapshot.val);
});
});
});
For instance, if the username 'javedh' is removed, the EventListener should trigger and print Child is tjaved
, which is the new top value in the database after the removal.
https://i.sstatic.net/z7kWA.png
I'm seeking assistance in finding an effective solution to this issue. Thank you!