arnoldssss
arnoldssss

Reputation: 488

How to delete data in Firebase?

I wanted to delete a key, but I have not been capable of achieve it. I'm trying with:

      ref.child("notifications").once("value", function(usersSnap) {
         var i = 0
         usersSnap.forEach(function(reciptsSnap) { //for every user
            reciptsSnap.forEach(function(reciptSnap) {

                  reciptSnap.forEach(function(c) {

if (reciptSnap.key=="jkk....."){
console.log("removed date nad its parent"+reciptSnap.key+" "+c.val())
reciptSnap.key.remove()  //did not work brings remove is not a function
}

enter image description here

Upvotes: 1

Views: 6167

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363627

The reciptSnap is a DataSnapshot, which contains data from a Database location.
It cannot be removed directly.

You can use:

reciptSnap.ref.remove() 

Upvotes: 3

Related Questions