title: Can I determine if a string is a MongoDB ObjectID?
body: <p>I am doing MongoDB lookups by converting a string to BSON. Is there a way for me to determine if the string I have is a valid ObjectID for Mongo before doing the conversion?</p>
  
  <p>Here is the coffeescript for my current findByID function. It works great, but I'd like to lookup by a different attribute if I determine the string is not an ID.</p>
  
  <pre><code>db.collection "pages", (err, collection) -&gt;
    collection.findOne
      _id: new BSON.ObjectID(id)
    , (err, item) -&gt;
      if item
        res.send item
      else
        res.send 404
  </code></pre>