Update a single variable in my entire collection in Firebase Firestore

Viewed 14

I want to update a variable after click the button. This is my collection in firestore, and this is my variable what i want to update. Firestore Collection

That variable "bagAmount", after click I want all of them to be equal to 1. I know how update one of then, past the ID of my document, like that:

this.firestore.doc("lunch/" + this.bagIndex).update({bagAmount: 1});

But how i update all? Thanks!

1 Answers

Several methods exist for writing data to Cloud Firestore:

  • By specifically mentioning a document identifier, set the data for the document within a collection. Add a fresh document to a repository.

  • In this instance, the document identifier is generated automatically by Cloud Firestore.

  • Create a blank document with a randomly generated identification, then fill it with information afterward.

Related