Reputation:
I am trying to programmatically clear a Firebase realtime database. In the Firebase console, I know how to empty the database by clicking on the database name and hitting "clear", but how am I able to do it through Javascript? is there a .clear()
or .empty()
command for the database I can use in Vanilla JS?
Upvotes: 0
Views: 110
Reputation: 598728
To make the Firebase Realtime Database empty, you can delete its root node.
So something like:
firebase.database().ref().remove();
Upvotes: 1
Reputation: 83058
You just have to call remove()
on the Reference that points to the root of the database, as follows:
var rootRef = firebase.database().ref();
rootRef.remove();
Upvotes: 0