From d142e6c553cf0455b8718d2bc407c43591f3f75f Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Wed, 13 Jul 2016 10:03:00 +0430 Subject: [PATCH] fix(options): take a `name` parameter, same as the `name` parameter used in `hapi-sequelize`, fixes #8 --- README.md | 1 + package.json | 2 +- src/index.js | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44801af..32c94ad 100644 --- a/README.md +++ b/README.md @@ -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 } }); diff --git a/package.json b/package.json index 6d6b4fd..ac43526 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/index.js b/src/index.js index b414be8..320bf83 100644 --- a/src/index.js +++ b/src/index.js @@ -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) {