title: Mongo and Node.js: Finding a document by _id using a UUID (GUID)
body: <p>I'm developing a restAPI using node.js and i'm trying to query a mongo collection. I can query using strings (for example "companyname") but I need to be able to query the "_id" element in the document. <br /><br /></p>
  
  <p>In mongo the _id is currently stored like this (as a GUID):</p>
  
  <pre><code>{
  "_id" : new BinData(3, "MH+t3q6PD0SxVR5z7/pzfw=="), 
  "companyname" : "TestCompany",
  "databasename" : "TestDataBase",
  }
  </code></pre>
  
  <p><br />
  This is what my current GET method looks like:
  <br /></p>
  
  <pre><code>exports.getBusinessCardData = function(req, res) {
      var id = req.params.id;
      //"id" = MH+t3q6PD0SxVR5z7/pzfw==
  
      tradeShowAdminDB.collection('clients', function(err, collection) {
          collection.findOne({'_id': id}, function(err, item) {
              res.send(item);
          });
      });
  };
  </code></pre>
  
  <p>The "id" coming into the method is Base64 string format ("MH+t3q6PD0SxVR5z7/pzfw==") and using that  the query returns nothing (i'm assuming as it's not the correct type/format). My question is how do I get that "id" into the correct format so that I can query mongo using the _id?</p>
  
  <p>I've been looking for ages and can't seem to find a solution and the documentation seems very vague on anything that isn't a 24 character hex ObjectId. Any help would be very much appreciated! 
  <br />
  <br />
  Additional information:</p>
  
  <p>I'm using node v0.10.33 and express v4.x</p>
  
  <p>The mongo driver I am using is just the base javascript mongo driver for node. <br />
  (found here: <a href="http://docs.mongodb.org/ecosystem/drivers/node-js/" rel="nofollow">http://docs.mongodb.org/ecosystem/drivers/node-js/</a>)</p>