3

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

6
  • My first recommendation (without reading any further) is to upgrade to a more recent version of the Firebase SDK. The new Firebase syntax has been superseded over 1.5 years ago. For help in upgrading the code, see firebase.google.com/support/guides/… Commented Sep 14, 2017 at 14:10
  • That warning should not prevent your code from working. It just warns you that the code is inefficient. See some of the previous developers who had this warning: google.com/… Commented Sep 14, 2017 at 14:11
  • but the value is not remove from firebase ? Commented Sep 14, 2017 at 14:19
  • That could be, but it's unrelated to the warning message. Is you child_added callback being invoked? Commented Sep 14, 2017 at 14:28
  • No. There is no change happening in firebase after this execution. Commented Sep 14, 2017 at 14:31

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.