Created
April 5, 2013 11:03
-
-
Save afshinm/5318469 to your computer and use it in GitHub Desktop.
Example of MongoDb singleton connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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