title: How to update some but not all fields in Mongoose
body: <p>here is the UserSchema:</p>
  
  <pre><code>var UserSchema = new Schema({
      username: { type: String, required: true, index:{unique: true} },
      firstName: { type: String, required: true },
      lastName: { type: String, required: true },
      email: { type: String, required: true, index:{unique: true} }, 
      password: { type: String, required: true, select: false }
  });
  </code></pre>
  
  <p>Here is the http PUT request:</p>
  
  <pre><code>  // update user information
    api.put('/users/:username', function(req, res) {
  
      User.findOne({username: req.params.username}, function(err, user) {
  
        if (err){
          res.send(err);
          return;
        }
  
        if (!user){
          res.status(404).send({
            success: false,
            message: "user not found"
          });
        } else {
          user.username = req.body.username;
          user.email = req.body.email;
          user.password = req.body.password;
          user.firstName = req.body.firstName;
          user.lastName = req.body.lastName;
  
          user.save(function(err) {
            if (err){
              res.send(err);
              return;
            }
  
            res.json({
              success: true,
              message: "user information updated."
            });
          });
        }
      });
    });
  </code></pre>
  
  <p>The question is, if the user only want to update limited fields, for example, only update username, then the above code does not work, the error looks like this:</p>
  
  <pre><code>{
    "message": "User validation failed",
    "name": "ValidationError",
    "errors": {
      "lastName": {
        "properties": {
          "type": "required",
          "message": "Path `{PATH}` is required.",
          "path": "lastName"
        },
        "message": "Path `lastName` is required.",
        "name": "ValidatorError",
        "kind": "required",
        "path": "lastName"
      },
      "firstName": {
        "properties": {
          "type": "required",
          "message": "Path `{PATH}` is required.",
          "path": "firstName"
        },
  .........
  </code></pre>
  
  <p>so how can I implemement to allow user updates some but not all fields?</p>
  
  <p>Any comments and suggestions are appreciated!</p>