title: Update embedded document mongoose
body: <p>I'm looking for an easy way of updating an embedded document using mongoose without having to set each specific field manually. Looking at the accepted answer to <a href="https://stackoverflow.com/questions/7035092/how-to-update-embedded-document-in-mongoose">this question</a>, once you find the embedded document that you want to update you have to actually set each respective property and then save the parent. What I would prefer to do is pass in an update object and let MongoDB set the updates.</p>
  
  <p>e.g. if I was updating a regular (non embedded) document I would do this:</p>
  
  <pre><code>models.User.findOneAndUpdate({_id: req.params.userId}, req.body.user, function(err, user) {
      err ? resp.status(500).send(err) : user ? resp.send(user) : resp.status(404).send();
  });
  </code></pre>
  
  <p>Here I don't actually have to go through each property in req.body.user and set the changes. I can't find a way of doing this kind of thing with sub documents as well ?</p>
  
  <p>My Schema is as follows:</p>
  
  <pre><code>var UserSchema = BaseUserSchema.extend({ 
      isActivated: { type: Boolean, required: true },
      files: [FileSchema]
  });
  
  var FileSchema = new mongoose.Schema(
      name: { type: String, required: true },
      size: { type: Number, required: true },
      type: { type: String, required: true },
  });
  </code></pre>
  
  <p>And I'm trying to update a file based on user and file id.</p>
  
  <p>Do I need to create a helper function to set the values, or is there a MongoDB way of doing this ?</p>
  
  <p>Many thanks.</p>