title: db in db.collection.... is undefined, and I can't figure out why
body: <p>Here is my server.js file. In my get '/' route, I keep getting db is not defined. I am trying to post retrieve documents from a mongodb collection, and eventually have the user be able to query the database using a document key:value. Any thoughts?</p>
  
  <pre><code>var express = require('express');
  var bodyParser = require('body-parser');
  var app = express();
  var mongoose = require('mongoose');
  
  mongoose.connect('mongodb://&lt;dbuser&gt;:&lt;dbpassword&gt;@ds061355.mlab.com:61355/db');
  
  app.use(bodyParser.urlencoded({extended: true}))
  
  app.get('/', (req, res) =&gt; {
      res.sendFile(__dirname + '/index.html');
  });
  
  
  
  app.get('/:name', (req, res) =&gt; {
      var cursor = db.collection('materials').find();
      db.collection('materials').find().toArray(function(err, results) {
          console.log(results);
      });
  
  });
  
  app.listen(3000, () =&gt; {
      console.log('Running app.js on 3000');
  });
  </code></pre>