hapi-massive-models
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

hapi-massive

Hapi plugin for massive.js 2.0

Install

var plugin = {
  register: require("hapi-massive"),
  options: {
    connectionString: "postgres://username:password@localhost/database"
  }
};
 
server.register(plugin, function(error){
  if(error){
    console.error("failed to load plugin: ", err);
  }
}

hapi-massive comes free with promises! Promises wrap all your sql files as well as the relational bits

Examples

Clean code! (Say that you have a table named user and a sql file named createUser.sql that returns a user object upon creation)

var db = request.plugins["hapi-massive"].db;
var userdeets = [...userinfo];
db.createUserAsync().then(function(user){
  console.log("woot! user created. ", user); 
});

Or go crazy with generators! (using co.js)

var db = request.plugins["hapi-massive"].db;
co(function*(){
  var userdeets = [...userinfo];
  var user = yield db.createUserAsync(userdeets); // wow does this look like its in sync or what?
  console.log(user);
}).catch(function(err){
  console.log("there can't be errors in an example!");
});

Special thanks

Heavily inspired by hapi-node-postgres.

Promises brought to you by bluebird

Readme

Keywords

none

Package Sidebar

Install

npm i hapi-massive-models

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • zmanian