This is just a prettier and easier way to utilize the default node.js mongo db driver with a node web framework like Hapi or Express.
We are setting up our database connection, getting our db object, and storing it in our web framework so we can access it throughout our application.
If the syntax looks a little bit funky, it's because I'm using ES6. Check out https://babeljs.io/docs/learn-es6
Example
The example is using the Hapi framework. The idea is the same if you're using express. See: http://expressjs.com/4x/api.html#app.locals - You can access it on the request object just like in the hapi example below.
let db = req.app.locals.db