npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

mydb-preload

0.1.0

@rauchg

npmSnykSocket
Downloads:72
$ npm install mydb-preload
DailyWeeklyMonthlyYearly

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');
});