title: MongoDB db.collection.save overwrite object when existing
body: <p>In MongoDB, you can use <code>db.collection.save({_id:'abc'}, objectToSave)</code> to perform an upsert. </p>
  
  <p>Let's define objectToSave as below</p>
  
  <pre><code>{_id:'abc', field1:1, field2:2};
  </code></pre>
  
  <p>In my collection, I have already have a document with same _id value as below: </p>
  
  <pre><code>{_id:'abc', field3:3};
  </code></pre>
  
  <p>The save function above will replace the existing document in collection to </p>
  
  <pre><code>{_id:'abc', field1:1, field2:2};
  </code></pre>
  
  <p>What I want is to perform a $set operation to produce some document in collection as below</p>
  
  <pre><code>{_id:'abc', field1:1, field2:2, field3:3};
  </code></pre>
  
  <p>Can this be achieved in the save function or I have to write separate update statements? </p>
  
  <p>Note that objectToSave's fields are dynamic. The language I'm using is Node.JS. </p>