1

I have decided to use firebase firestore for my new android app after using mysql for a while.

In mysql, I could go to the database and add a new column directly and it will have effect on all existing records.

For firestore, I dont see the option to add a new field to all existing documents. I am only seeing add field for a single docuement. This will be so hard if you have so many records, updating each documents with a new field will be time consuming.

So, I ask is there a place in firestore where I can add a new fields to all existing documents in a collection.

E.G I have users collection with each document containing first_name, last_name etc.

Now, I have decided to add the phone_number field to all documents with an empty value for ALL the documents, how do I do that with cloud firestore console.??

Ibramazin
  • 958
  • 10
  • 30
  • 2
    There are no update queries in Cloud Firestore's API. . You'll need to read all documents, and update them one at a time, or in batches. See https://stackoverflow.com/a/48950404 – Frank van Puffelen Apr 15 '20 at 16:07
  • I can add a field to a single document in the console but not to the ENTIRE documents.... That's what I am asking. – Ibramazin Apr 15 '20 at 16:10
  • 1
    Same thing: there is no way to modify all documents in one go. You'll have to update each document in turn. – Frank van Puffelen Apr 15 '20 at 16:12
  • You can also check **[this](https://stackoverflow.com/questions/54070668/cloud-firestore-how-to-set-a-field-in-document-to-null/54071216#54071216)** and **[this](https://stackoverflow.com/questions/52179367/how-to-update-one-field-from-all-documents-using-pojo-in-firestore)** out. – Alex Mamo Apr 16 '20 at 09:28

0 Answers0