title: If value of a property is null when updating then that property should not be added to the record
body: <p>Suppose I have a mongoose schema like this:</p>
  
  <pre><code>var mongoose = require('mongoose');
  var Schema = mongoose.Schema;
  
  var testSchema = new Schema({
      name: {type: String, required: true},
      nickName: {type: String}
  });
  
  var Test = module.exports = mongoose.model('Test', testSchema);
  </code></pre>
  
  <p>I declare methods for CRUD operation using variable Test. From that one such method is update, which is defined as follows:</p>
  
  <pre><code>module.exports.updateTest = function(updatedValues, callback) {
  
      console.log(updatedValues); //this output is shown below
  
      Test.update(
          { "_id": updatedValues.id },
          { "$set" : { "name" : updatedValues.name, "nickName" : updatedValues.nickName } },
          { multi: false },
          callback
      );
  
  };
  </code></pre>
  
  <p>Now, I use this method inside my node router as follows:</p>
  
  <pre><code>router.put('/:id', function(req, res, next) {
  
      var id = req.params.id,
      var name = req.body.name,
      var nickName = req.body.nickName
  
      req.checkBody("name", "Name is required").notEmpty();
  
      var errors = req.validationErrors();
  
      if(errors) { ........ }
      else {
  
          var testToUpdate = new Test({
              _id: id,
              name: name,
              nickName: nickName || undefined
          });
  
          Test.updateTest(testToUpdate, function(err, result) {
              if(err) { throw(err); }
              else { res.status(200).json({"success": "Test updated successfully"}); }
          });
  
      }
  });
  </code></pre>
  
  <p>Now if I save a new record in database and then see it in database then it looks like:</p>
  
  <pre><code>{
      "_id" : ObjectId("ns8f9yyuo32hru0fu23oh"), //some automatically generated id 
      "name" : "firstTest",
      "__v" : 0
  }
  </code></pre>
  
  <p>Now if I update the same document without changing anything and then if I take a look at same record in database, then I get:</p>
  
  <pre><code>{
      "_id" : ObjectId("ns8f9yyuo32hru0fu23oh"), //some automatically generated id 
      "name" : "firstTest",
      "__v" : 0,
      "nickName" : null
  }
  </code></pre>
  
  <p>Can you see that nickName is set to null? I don't want it to work like this. I want that if my property is null, then that property should not be included in the record.</p>
  
  <p>If you remember, I have console logged the updatedValues before updating it. (see the second code block in question). So, here is the logged values:</p>
  
  <pre><code>{
      "_id" : ObjectId("ns8f9yyuo32hru0fu23oh"), //some automatically generated id 
      "name" : "firstTest"
  }
  </code></pre>
  
  <p>I don't know why, but nickName is not present in the logged values and then after update I get <code>nickName: null</code>. I think, the problem lies in second Code block. Can you please check it?</p>
  
  <p><strong>Note:</strong></p>
  
  <p>Actually I have lot more fields in my schema than I specified in question. Some fields are reference to other records as well.</p>