fix(options): take a name
parameter, same as the name
parameter used in hapi-sequelize
, fixes #8
This commit is contained in:
parent
fb06d9cd27
commit
d142e6c553
@ -28,6 +28,7 @@ await register({
|
|||||||
register: require('hapi-sequelize-crud'),
|
register: require('hapi-sequelize-crud'),
|
||||||
options: {
|
options: {
|
||||||
prefix: '/v1',
|
prefix: '/v1',
|
||||||
|
name: 'db', // the same name you used for configuring `hapi-sequelize` (options.name)
|
||||||
defaultConfig: { ... } // passed as `config` to all routes created
|
defaultConfig: { ... } // passed as `config` to all routes created
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hapi-sequelize-crud",
|
"name": "hapi-sequelize-crud",
|
||||||
"version": "2.2.0",
|
"version": "2.3.0",
|
||||||
"description": "Hapi plugin that automatically generates RESTful API for CRUD",
|
"description": "Hapi plugin that automatically generates RESTful API for CRUD",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"config": {
|
"config": {
|
||||||
|
@ -9,7 +9,8 @@ import qs from 'qs';
|
|||||||
const register = (server, options = {}, next) => {
|
const register = (server, options = {}, next) => {
|
||||||
options.prefix = options.prefix || '';
|
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 models = db.sequelize.models;
|
||||||
|
|
||||||
const onRequest = function (request, reply) {
|
const onRequest = function (request, reply) {
|
||||||
|
Loading…
Reference in New Issue
Block a user