title: Mongojs & Express - Can't delete by id
body: <p>I am trying to delete records based on ID.  I am sending the ID via the get verb and acessing it from req.params.id.  My code isn't working.  What am I doing wrong?</p>
  
  <pre><code>//delete user
  router.get('/deleteuser/:id', function(req, res){
      var db = req.db;
      db.users.remove({'_id':req.params.id}, function(err, docs) {
          if (err) return err;
          res.send(docs); // see results
      });
  });
  </code></pre>
  
  <p>I realize I need to add "ObjectId" before req.params.id.  However, concatenating is not working.  I have this so far.  Is there another way:</p>
  
  <pre><code>//delete user
  router.get('/deleteuser/:id', function(req, res){
      var db = req.db;
      var objId = 'ObjectId("' + req.params.id + '")';
      console.log(objId);
      db.users.remove({"_id": objId}, function(err, docs) {
    //db.users.remove({"_id": ObjectId("4d512b45cc9374271b02ec4f")});  works in mongo console
          if (err) return err;
          console.log(docs);
          res.send(docs);
      });
  });
  </code></pre>
  
  <p>This worked:</p>
  
  <p>// db.ObjectId(req.params.id)</p>
  
  <pre><code>router.get('/deleteuser/:id', function(req, res){
      var db = req.db;
      db.users.remove({"_id": db.ObjectId(req.params.id)}, function(err, docs) {  //db.users.remove({"_id": ObjectId("4d512b45cc9374271b02ec4f")});
          if (err) return err;
          console.log(docs);
          res.send(docs);
      });
  });
  </code></pre>