user9545614
user9545614

Reputation:

How to programatically clear Firebase Realtime Database

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

Answers (2)

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

To make the Firebase Realtime Database empty, you can delete its root node.

So something like:

firebase.database().ref().remove();

Upvotes: 1

Renaud Tarnec
Renaud Tarnec

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

Related Questions