title: fastify-mongodb : "mongo" is undefined when accessed
body: <p>I'm attempting to use Fastify and fastify-monogdb.
  Currently I have the following...</p>
  
  <p>In my <strong>/src/index.js</strong>  </p>
  
  <pre class="lang-js prettyprint-override"><code>const routes = require("./routes");
  const fastify = require("fastify")({
    logger: true
  });
  
  routes.forEach((route, index) =&gt; {
    fastify.route(route);
  });
  
  fastify.register(require("fastify-mongodb"), {
    url: "mongodb://localhost:27017/parkedcars"
  });
  
  const startFastify = async () =&gt; {
    try {
      await fastify.listen(3333);
      fastify.log.info(`server listening on ${fastify.server.address().port}`);
    } catch (err) {
      fastify.log.error(err);
      process.exit(1);
    }
  };
  
  startFastify();
  </code></pre>
  
  <p>In my <strong>/routes/index.js</strong> I have a route...</p>
  
  <pre class="lang-js prettyprint-override"><code>const carController = require("../controllers/carController");
  
    {
      method: "POST",
      url: "/api/create/parkedcar",
      handler: carController.createParkedCar
    }
  </code></pre>
  
  <p>And finally in my <strong>/controllers/carController</strong>...</p>
  
  <pre class="lang-js prettyprint-override"><code>const fastify = require("fastify")();
  
    exports.createParkedCar = async (req, reply) =&gt; {
    try {
      let car = { ...req.body };
      const db = fastify.mongo.db
      *// will do insert here*
      return car;
    } catch (err) {
      throw boom.boomify(err);
    }
  };
  </code></pre>
  
  <p>When I attempt to call:<br>
  <strong>const db = fastify.mongo.db</strong>  </p>
  
  <p>I get an error that says...<br>
  <strong>"Cannot read property 'db' of undefined"</strong>  </p>
  
  <p>What am I doing wrong here?<br>
  How is <strong>mongo</strong> undefined at this point?<br>
  Doesn't "fastify.register" make this accessible to me?</p>