fix(crud): see 83eadf0929
and #37
This commit is contained in:
parent
85b52fd5ab
commit
a6590a9650
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hapi-sequelize-crud",
|
"name": "hapi-sequelize-crud",
|
||||||
"version": "2.9.2",
|
"version": "2.9.3",
|
||||||
"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": {
|
||||||
|
12
src/index.js
12
src/index.js
@ -37,7 +37,6 @@ const register = (server, options = {}, next) => {
|
|||||||
|
|
||||||
// Join tables
|
// Join tables
|
||||||
if (model.options.name.singular !== model.name) continue;
|
if (model.options.name.singular !== model.name) continue;
|
||||||
crud(server, model, options);
|
|
||||||
|
|
||||||
for (const key of Object.keys(model.associations)) {
|
for (const key of Object.keys(model.associations)) {
|
||||||
const association = model.associations[key];
|
const association = model.associations[key];
|
||||||
@ -93,6 +92,17 @@ const register = (server, options = {}, next) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// build the methods for each model now that we've defined all the
|
||||||
|
// associations
|
||||||
|
Object.keys(models).filter((modelName) => {
|
||||||
|
const model = models[modelName];
|
||||||
|
return model.options.name.singular === model.name;
|
||||||
|
}).forEach((modelName) => {
|
||||||
|
const model = models[modelName];
|
||||||
|
crud(server, model, options);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user