Skip to content

Instantly share code, notes, and snippets.

@cybear
Created January 27, 2012 12:38
Show Gist options
  • Save cybear/1688595 to your computer and use it in GitHub Desktop.
Save cybear/1688595 to your computer and use it in GitHub Desktop.
Database Middleware proof of concept
function dbMiddleware(req, res, next){
db.collection('people', function(err, collection){
if(!err){
collection.find().toArray(function(err, items){
if(!err){
req.db=items;
next();
} else next('Sad collection');
})
} else next('Sad DB');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment