Reputation: 121
Is it possible to delete data from Firebase from within the application. I currently can add, amend and delete data directly from the console which updates in the application using the child_added, child_changed and child_removed.
Also, I can add data to Firebase using .push which also reflects the changes with the application.
However, I cannot find anything within the documentation to suggest how to remove data from Firebase through the application - Something like a bin icon next to each Firebase object which when clicked will remove that piece of data from the Firebase database and update within the application.
Is this possible? I'm going round in circles and still can't crack it. Any help would be greatly appreciated.
Thanks, G
Upvotes: 0
Views: 3214
Reputation:
You can do it in two ways.
firebase.database().ref(CHILD_TO_DELETE).remove();
or
firebase.database().ref(CHILD_TO_DELETE).set(null);
Something like a bin icon next to each Firebase object which when clicked will remove that piece of data from the Firebase database and update within the application.
The answer to this part is it can be inside a click event function of maybe a delete button.
Upvotes: 1
Reputation: 138824
For JS
please use this code:
ref = new Firebase("myfirebase.com")
ref.remove();
Hope it helps.
Upvotes: 2
Reputation: 297
ref.child(key).remove();
In JS you could do it like shown above. Keep in mind, it´s asynchronus.
Upvotes: 0