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 hopefully the following snippet would help you out as well. If you do not think this is the right way, please leave a comment.
var app = express();
var mongodb = require('mongodb').MongoClient, format = require('util').format;
mongodb.connect('mongodb://127.0.0.1:27017/myday', function(err, db){
app.get('/api/v1/put/:var1/:var2', function(req, res){
collection = db.collection('collection');
.. logic ...
});
app.listen(8000);
});
Having read this I thought it was very informative.
I appreciate you finding the time and energy to put this short article together.
I once again find myself personally spending a lot of time both reading and posting comments.
But so what, it was still worth it!
Thank you a lot for sharing this with all of us you actually know what
you are talking about! Bookmarked. Please additionally consult with my website =).
We could have a link alternate agreement between us