Skip to content

Instantly share code, notes, and snippets.

@afshinm
Created April 5, 2013 11:03
Show Gist options
  • Save afshinm/5318469 to your computer and use it in GitHub Desktop.
Save afshinm/5318469 to your computer and use it in GitHub Desktop.
Example of MongoDb singleton connection
var mongoDbConnection = require('./lib/connection.js');
exports.index = function(req, res, next) {
mongoDbConnection(function(databaseConnection) {
databaseConnection.collection('collectionName', function(error, collection) {
collection.find().toArray(function(error, results) {
//blah blah
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment