title: Firestore update with merge - how to overwrite a part of the document
body: <p>When updating a document in Firestore, I want to keep most of the document, but change one property which contains an object.</p>
  
  <p><strong>What I have</strong></p>
  
  <pre><code>{
    name: "John Doe",
    email: "me@example.com",
    friends: {
       a: {...},
       b: {...},
       c: {...},
       d: {...},
       e: {...},
       f: {...},
    }
  }
  </code></pre>
  
  <p>Now, I have a new friends object like <code>{x: ..., y: ..., z: ...}</code></p>
  
  <p>I want to overwrite the <code>friends</code> tree of my document, but keep all other fields.</p>
  
  <p><strong>What I want it to look like</strong></p>
  
  <pre><code>{
    name: "John Doe",
    email: "me@example.com",
    friends: {
       x: {...},
       y: {...},
       z: {...},
    }
  }
  </code></pre>
  
  <p>However, if I do a <code>firestore.doc(...).update({friends: {...}}, { merge: true })</code></p>
  
  <p><strong>What I currently get</strong></p>
  
  <pre><code>{
    name: "John Doe",
    email: "me@example.com",
    friends: {
       a: {...},
       b: {...},
       c: {...},
       d: {...},
       e: {...},
       f: {...},
       x: {...},
       y: {...},
       z: {...},
    }
  }
  </code></pre>
  
  <p>I know that I can do two updates, i.e. delete the field and then set it again, or I can read the document, change the object and save it without merging. </p>
  
  <p>But isn't there a smart way to overwrite an object (map) while keeping the rest of the document untouched?</p>