Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Difference Between Firestore Set with {merge: true} and Update

Understand the difference between Firestore set with {merge: true} and Update to avoid duplication of functionality.

Quick Answer: Use 'set' with merge: true for initial document creation, and use 'update' for subsequent updates.

In Cloud Firestore, there are three write operations: add(), set(), and update(). The documentation states that using set(object, { merge: true }) will merge the given object with the existing document. Similarly, when you use update(object), it also merges the new data with the existing document.

🔍 Why This Happens

  • The reason for this duplication lies in the way Firestore handles data modifications.

🚀 How to Resolve This Issue

Method 1: Using set(object, { merge: true })

  1. Step 1: When using set(object, { merge: true }), Firestore will automatically merge the new data with the existing document.

Method 2: Using update(object)

  1. Step 1: When using update(object), you should specify the fields to be updated and their new values.

✨ Wrapping Up

In conclusion, while usingset(object, { merge: true }) and update(object) may seem like the same operation, they have different use cases. By understanding the differences between these two methods, you can write more efficient and effective Cloud Firestore queries.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions