hapi-pg-promise-multi
v1.0.4
Published
Wrap requests with a pg connection.
Downloads
4
Readme
hapi-pg-promise-multi
Wrap requests with a Postgres connection using promises.
We use the pg-promise
(pg-promise
)
Install
$ npm install hapi-pg-promise-multi
Usage
In your request handlers you'll have access to request.BASE_NAME
which you
can use to make DB requests.
server.plugins['hapi-pg-promise'].BASE_NAME
is available outside of request
handlers.
Hapi 18
Current version works with Hapi 18.x.x. For older versions use 1.0.0 of hapi-pg-promise.
Register the plugin
const hapiPgPromise = require('hapi-pg-promise-multi');
const plugin = {
plugin: hapiPgPromise,
options: [{
cn: 'postgres://username:password@host:port/database',
name: 'BASE_NAME',
settings: {
// pg-promise options
}
},{
cn: 'postgres://username:password@host:port/database_next',
name: 'BASE_NAME_NEXT',
settings: {
// pg-promise options
}
}]
};
server.register(plugin);
Original
License
MIT