Remove multiple records from Firebase Realtime database - Nodejs

Viewed 1264

Is there a possibility of removing multiple nodes from a Firebase Realtime database in one go? I can delete a record by giving the full path of the child node. But if I have multiple child node keys already, is there a way I can delete all of them at once?

1 Answers

You can remove multiple nodes in one go by using a multi-location update statement, and passing null for the values.

Something like:

const ref = firebase.database().reference();
ref.update({
  "/path/to/node/one": null,
  "/path/to/node/two": null,
  "/path/to/node/three": null
});
Related