title: Update single record in mongodb using express and node.js
body: <p>I want to update a single record by _id in a collection in mongoDB.</p>
  
  <p>UPDATE:  I changed the res to req (thanks!) and implemented the db.ObjectId() around the objectId I am passing in and now I get a 500 internal server error.</p>
  
  <pre><code>    "_id" : ObjectId("54d5296711436278137af74b"),
      "username" : "alex",
      "email" : "alex@gmail",
      "fullname" : "alex man",
      "age" : "15",
      "location" : "minneap",
      "gender" : "mal"
  </code></pre>
  
  <p>This is my ajax call from the client.</p>
  
  <pre><code>    $.ajax({
                      type: 'PUT',
                      data: updatedUser,
                      url: '/users/updateuser/' + globalUserID,
                      dataType: 'JSON'
                  }).done(function(response){
  </code></pre>
  
  <p>This is the routing code.</p>
  
  <pre><code>/*
  * PUT to updateuser
  */
  router.put('/updateuser/:id', function(req, res) {
  var db = req.db;
  var userToUpdate = req.params.id;
  db.collection('userlist').update(
  { _id: userToUpdate},
     req.body,
      function(err, result){
      res.send(
          (err === null) ? {msg: ''} : {msg: err}
      );
     });
  });
  </code></pre>
  
  <p>I get a 200 response back but my record is not updated. What is wrong with my syntax?</p>