0
votes

I do not understand the following paragraph from Firestore doc

https://firebase.google.com/docs/firestore/manage-data/add-data

If you're not sure whether the document exists, pass the option to merge the new data with any existing document to avoid overwriting entire documents.

How can it overwrite entire documents?

1

1 Answers

0
votes

Read the paragraph just before that one:

If the document does not exist, it will be created. If the document does exist, its contents will be overwritten with the newly provided data, unless you specify that the data should be merged into the existing document,

It's saying that when you call set(), you will overwrite the document with new data. Then, it's saying if you don't want to that, and instead update the existing data, pass a flag to tell it to merge the given data with the existing data.