title: How do you find by id using the MongoDB Node driver?
body: <p>I'm looking for the best way to find by id using the <a href="http://mongodb.github.io/node-mongodb-native/2.0/" rel="nofollow">MongoDB Node driver</a>.</p>
  
  <p>I see that the <code>_id</code> field is an <code>ObjectId</code>, and so using a string for the id won't work. And I see that you <a href="http://mongodb.github.io/node-mongodb-native/2.0/tutorials/objectid/" rel="nofollow">could use ObjectId</a> as follows:</p>
  
  <pre><code>var ObjectId = require('mongodb').ObjectId;
  
  exports.show = function(req, res) {
    var db = req.app.get('db');
    var id = new ObjectId(req.params.id);
    db.collection('posts').findOne({
      _id: id
    }, function(err, post) {
      res.status(200).json(post);
    });
  };
  </code></pre>
  
  <p>But is there a best practice/more convenient way? I hadn't come across one in looking through the docs. Note: Mongoose has a <a href="http://mongoosejs.com/docs/api.html#model_Model.findById" rel="nofollow">findById</a> method where you could just use the id string.</p>