Jishad
Jishad

Reputation: 2965

Remove item from firebase array with value using jquery

I want to remove a value from firebase database with value using jquery.

enter image description here

I want to delete 235 value from the firebase.

I tried..

var dbRef = new Firebase("https://afgani-cinemas.firebaseio.com/");
var showId = getUrlParameter('showId');
var bookings = dbRef.child('bookings/'+showId);

 function removeFromFB(seatId){
    dbRef.orderByValue().equalTo().on('child_added', function(snapshot){
      snapshot.dbRef().remove();
    });
}

removeFromFB(235);

Any suggestions in my code. Its not working!!!

getting warning like this

firebase.js:40 FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": ".value" at / to your security rules for better performance

Upvotes: 3

Views: 1082

Answers (1)

Muneef M
Muneef M

Reputation: 1114

Try using this code snippet

var bookings = firebase.child('root/321');
 function removeFromFB(valu){
    bookings.on('child_added', function(data) {
        if(data.val()==valu){
            bookings.child(data.key()).remove();
        }

});
}
removeFromFB(deleteValue);

in your case "deleteValue" will be 235

Upvotes: 3

Related Questions