I'd like to reuse the MongoClient connection in my routes (I have seen that there are ways using the old connectivity however I'd like to use MongoClient and I'd also like to have a separate DB configuration file
app.js (snippet)
var route = require('route');
app.get("/", route.test);
dbconf.js
var MongoClient = require('mongodb').MongoClient;
var mongourl = 'mongodb://localhost/test';
MongoClient.connect(mongourl, function(err, db) {
if(err) console.log('Error connecting to ' + mongourl + ': ' + err);
var coll = db.collection('testcollection');
});
route.js (snippet)
exports.test = function(req, res) {
//i would like to use the connection created in dbconf.js here
}