0.0.4 • Published 7 years ago

dm-massifier v0.0.4

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

dm-massifier

Caches a massive instance, making it easy to share your db instance throughout your application

Massivejs is a wonderful SQL layer for Node. However, using it can be tricky sometimes.

dm-massifier adds a middleware layer that allows you to expose the db instance through the req object in Express.

Usage

index.js

const app         = require('express')(),
      massive     = require('massive'),
      productCtrl = require('./productController'),
      massifier   = require('dm-massifier')('postgres://Brett@localhost/sandbox');



app.use(massifier.middleware());

app.get('/api/products', productCtrl.index);

app.listen(3000, () => {
  console.log('Listening on 3000...');
});

productController.js

exports.index = function(req, res) {

  req.db.read_products().then(products => {
    res.json(products);
  })
}
0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago