title: How to use express.js with native mongoDB driver
body: <p>I struggle while trying to do a simple mongoDB query from within my express app:</p>
  
  <h3>app.js</h3>
  
  <pre><code>var express = require('express');
  var routes = require('./routes');
  var user = require('./routes/user');
  var http = require('http');
  var path = require('path');
  var mongourl = ''; // omitted on SO
  var MongoClient = require('mongodb').MongoClient;
  var dbInstance;
  
  MongoClient.connect(mongourl, function(err, db) {
      db.on('open',function(){
          dbInstance = db;
      })
  });
  
  
  app.get('/', routes.index(dbInstance));
  
  http.createServer(app).listen(app.get('port'), function(){
  
  });
  </code></pre>
  
  <h3>routes/index.js</h3>
  
  <pre><code>exports.index = function(db){
    return function(req,res){
  
    }
  
  };
  </code></pre>
  
  <p>Do i understand correctly that the exports.index' paramter is a database instance? If so, why can't i do <code>db.getCollectionNames()</code>?</p>
  
  <p>How would i work with the database instance in my route?</p>