0

I am looking for a way to delete certain data from firestore.

For example, I would like to wipe out documents that include "OVER" in 'name' field. I tried to do this code. but it does not work. How should I do?

    firebase
    .firestore().collection("stack").where("name",">=","OVER").delete().then(() => {
        console.log("Document successfully deleted!");
    }).catch((error) => {
        console.error("Error removing document: ", error);
    });
user14232549
  • 405
  • 4
  • 17

1 Answers1

0

Firestore does not have the concept of update or delete queries, where you send a condition to the server and it updates/deletes the relevant documents. You will have to:

  1. Execute the query.
  2. Loop over the results.
  3. Delete each document.
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807