I tried searching on the web and found no obvious code samples of how reuse the mongodb.connection object. This is what I have currently and would anyone please verify if this is okay.
var app = express();
var mongodb = require('mongodb').MongoClient, format = require('util').format;
var db = null;
app.get('/api/v1/put/:var1/:var2', function(req, res){
collection = db.collection('collection');
/** .. logic ... **/
});
mongodb.connect('mongodb://127.0.0.1:27017/mydb', function(err, mdb){
db = mdb;
app.listen(8000);
});