title: MongoDB - Save vs Update for specific fields in document
body: <p>Using the MEAN stack, I'm attempting to have an admin account update another user's information, in this case, their title/role on the site.  The problem I have is that the only function available when editing a user is the save() function.  It might be that I can utilize the update function, and if that is the case please let me know, but it doesn't look possible:</p>
  
  <p><a href="https://i.stack.imgur.com/GG8Pd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GG8Pd.png" alt="enter image description here"></a></p>
  
  <p>The problem arises that when the user is saved, it creates a new document, and overwrites the user's password and salt to some value.  I'd like to be able to call an "update" function that will only update the one field, but I can't figure out how to.  Is there a way to do this with the save function?</p>
  
  <p>Relevant Code:</p>
  
  <pre><code>exports.updateUserRoles = function(req, res) { 
      var currUser = req.body;
      User.findById(currUser._id, function(err, user) {
      //user.roles = currUser.roles;
      user.save( { _id : '56467b28ba57d8d890242cfa', roles : 'admin' } );
  
      //THE BELOW WAS A PREVIOUS ATTEMPT
  
      /*user.save( function(err) {
          if (err) {
              return res.status(400).send({
                  message: errorHandler.getErrorMessage(err)
              });
          } else {
              res.jsonp(user);
              console.log('test2');
          }
      });*/
  });
  };
  </code></pre>
  
  <p>Trying something else that seems very close, but still not quite there yet.</p>
  
  <p>Here's what I'm running:</p>
  
  <pre><code>exports.updateUserRoles = function(req, res) { 
      var currUser = req.body;
      User.findById(currUser._id, function(err, user) {
          //user.roles = currUser.roles;
          //user.roles.set(0, 'admin');
          console.log('test');
          user.update(
              { _id: '56467b28ba57d8d890242cfa' },
              {
                $set: {
                  roles: 'admin',
                },
              }
          );
          console.log('test2');
      });
  };
  </code></pre>
  
  <p>Upon hitting the user.update line, we have the user in the local variables, seen:</p>
  
  <p><a href="https://i.imgur.com/gDcdLdg.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/gDcdLdg.png" alt="enter image description here"></a></p>
  
  <p>user.update goes into this Document.prototype.update function, seen:</p>
  
  <p><a href="https://i.imgur.com/8u1FPmp.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/8u1FPmp.png" alt="enter image description here"></a></p>
  
  <p>The args look to be building right, which _id we are targeting and what the action is, seen:</p>
  
  <p><a href="https://i.imgur.com/xRDGNBy.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/xRDGNBy.png" alt="enter image description here"></a></p>
  
  <p>But then after running, nothing seems to change.  I'm very much stumped.</p>