title: MongoDB is it possible to update only part of the document?
body: <p>I have this:</p>
  
  <pre><code>//users collection:
  {
    personal_info: {
      first_name: "John",
      address: {
        city: "New york",
        street: "A"
      }
    }
  }
  </code></pre>
  
  <p>I want to make the next update with this:</p>
  
  <pre><code>req.body = {
    "address.street": "B"
  }
  
  db.users.update({}, {$set: req.body}, err =&gt; {
    ...
  });
  </code></pre>
  
  <p>As you can see, I take the whole document and asks for mongo to update only what changed in the set.</p>
  
  <p>Is this possible?</p>
  
  <p>Instead Mongo takes the whole document and replace it and sets a new document:</p>
  
  <pre><code>{
     personal_info: {
       first_name: "John",
       address: {
         street: "B"
       }
     }
  } // notice that "address.city" is gone
  </code></pre>