0.1.0 • Published 10 years ago

mydb-preload v0.1.0

Weekly downloads
5
License
-
Repository
-
Last release
10 years ago

mydb-preload

Express helper to preload mydb documents

How to use

In your middleware, call preload with a given url and the respective promise:

require('mydb-preload'); // to extend the response prototype

app.use(function(req, res, next){
  res.preload('/user', db.findOne(req.session.userId));
});

Then make sure to include the respective middleware in the routes that will expose the documents:

var preload = require('mydb-preload');
app.get('/', preload(), function(req, res, next){
  res.render('homepage.jade');
});