title: mongodb set null in update
body: <p>I have to interchange the values of a document. </p>
  
  <pre><code>var query = {"_id" : ObjectId("53e1c254382f891cc600076d")};
  
  db.properties.find(query).forEach(function(prop){
     printjson({"_id":prop._id, "val":prop.val, "ua":prop.ua});
     db.properties.update(query, {$set:{ua: prop.val}},{$unset:{val:""}});
  });
  </code></pre>
  
  <p>Before update operation, document looks like this:</p>
  
  <pre><code>{
      "_id" : ObjectId("53e1c254382f891cc600076d"),
      "val" : 9876541,
      "ua" : null
  }
  </code></pre>
  
  <p>And after the update it turns to: </p>
  
  <pre><code>{
      "_id" : ObjectId("53e1c254382f891cc600076d"),
      "val" : 9876541,
      "ua" : 9876541
  }
  </code></pre>
  
  <p>But I expect it as:</p>
  
  <pre><code>{
      "_id" : ObjectId("53e1c254382f891cc600076d"),
      "val" : null,
      "ua" : 9876541
  }
  </code></pre>
  
  <p>But its not working. also setting <code>"val"</code> null <code>({$set:{val:null}})</code> directly it deleted my entire document.</p>