fix(options): take a name parameter, same as the name parameter used in hapi-sequelize, fixes #8

This commit is contained in:
Mahdi Dibaiee 2016-07-13 10:03:00 +04:30
parent fb06d9cd27
commit d142e6c553
3 changed files with 4 additions and 2 deletions

View File

@ -28,6 +28,7 @@ await register({
register: require('hapi-sequelize-crud'),
options: {
prefix: '/v1',
name: 'db', // the same name you used for configuring `hapi-sequelize` (options.name)
defaultConfig: { ... } // passed as `config` to all routes created
}
});

View File

@ -1,6 +1,6 @@
{
"name": "hapi-sequelize-crud",
"version": "2.2.0",
"version": "2.3.0",
"description": "Hapi plugin that automatically generates RESTful API for CRUD",
"main": "build/index.js",
"config": {

View File

@ -9,7 +9,8 @@ import qs from 'qs';
const register = (server, options = {}, next) => {
options.prefix = options.prefix || '';
const db = server.plugins['hapi-sequelize'].db;
const name = options.name || 'db';
const db = server.plugins['hapi-sequelize'][name];
const models = db.sequelize.models;
const onRequest = function (request, reply) {