title: MongoDB - findOne using the params id results in an empty object or an error
body: <p>I'm learning Express/Mongo(using mLab) by building a simple little app that I can create a list of clients and a single client detail page.</p>
  
  <p><strong>localhost:3000/clients</strong> renders the entire collection of '<em>clients</em>'</p>
  
  <p><strong>localhost:3000/clients/:id</strong> should render the specific client by id</p>
  
  <p>This is a collection: <em>clients</em> entry example from MongoDB (mLab):</p>
  
  <pre><code>{
      "_id": {
          "$oid": "57ba01d3ab462a0aeec66646"
      },
      "name": "ClientName",
      "address": {
          "street": "StreetName",
          "city": "Cityname",
          "state": "Statename",
          "zip": "1234"
      },
      "createDate": {
          "$date": "2016-08-21T19:32:35.525Z"
      }
  }
  </code></pre>
  
  <p>I successfully created an href on the <strong>/clients</strong> page with the id value that links to the specific client:</p>
  
  <pre><code>&lt;a href="/clients/&lt;%= client._id %&gt;"&gt;&lt;%= client.name %&gt;&lt;/a&gt;
  </code></pre>
  
  <p>Which correctly results in this:</p>
  
  <pre><code>http://localhost:3000/clients/57ba01d3ab462a0aeec66646
  </code></pre>
  
  <p>Here is my get function for <strong>/clients/:id</strong>:</p>
  
  <pre><code>app.get('/clients/:id', (req, res) =&gt; {
    db.collection('clients').findOne(req.params.id, (err, result) =&gt; {
      if (err) {
        handleError(res, err.message, "Failed to get clients.");
      } else {
        console.log(result);
        res.render('client.ejs', {client: result})
      }
    });
  })
  </code></pre>
  
  <p>Clicking on the link results in the following error:</p>
  
  <blockquote>
    <p>MongoError: query selector must be an object at
    Function.MongoError.create
    (/Users/username/Desktop/node/node_modules/mongodb-core/lib/error.js:31:11)
    at Collection.find
    [...]</p>
  </blockquote>
  
  <p>I've been reading and searching all afternoon and trying a ton of different options like:</p>
  
  <ul>
  <li>'You need to create an ObjectID': <a href="https://stackoverflow.com/a/10929670">https://stackoverflow.com/a/10929670</a></li>
  <li>'You need to use Mongoose to create the ObjectID': <a href="https://stackoverflow.com/a/30652361">https://stackoverflow.com/a/30652361</a></li>
  </ul>
  
  <p>Do I really need Mongoose? This seems like a foundational thing to do it Mongo — why isn't it working?</p>