fix(associate): associating one way is enough
fix(destroy): directly get a `destroy` method instead of find and destroy
This commit is contained in:
parent
afb08670e8
commit
544dc23723
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hapi-sequelize-crud",
|
"name": "hapi-sequelize-crud",
|
||||||
"version": "2.0.4",
|
"version": "2.0.5",
|
||||||
"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": {
|
||||||
|
@ -26,13 +26,9 @@ export default (server, a, b, names, options) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const fna = getMethod(instancea, names.b, false, 'add') ||
|
const fn = getMethod(instancea, names.b, false, 'add') ||
|
||||||
getMethod(instancea, names.b, false, 'set');
|
getMethod(instancea, names.b, false, 'set');
|
||||||
const fnb = getMethod(instanceb, names.a, false, 'add') ||
|
await fn(instanceb);
|
||||||
getMethod(instanceb, names.a, false, 'set');
|
|
||||||
|
|
||||||
fnb(instancea);
|
|
||||||
fna(instanceb);
|
|
||||||
|
|
||||||
reply([instancea, instanceb]);
|
reply([instancea, instanceb]);
|
||||||
}
|
}
|
||||||
|
@ -157,11 +157,9 @@ export const destroy = (server, a, b, names) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const method = getMethod(base, names.b);
|
const method = getMethod(base, names.b, true, 'destroy');
|
||||||
const list = await method({ where, include });
|
const list = await method({ where, include });
|
||||||
|
|
||||||
await* list.map(instance => instance.destroy());
|
|
||||||
|
|
||||||
reply(list);
|
reply(list);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -185,7 +183,7 @@ export const destroyScope = (server, a, b, names) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const method = getMethod(base, names.b);
|
const method = getMethod(base, names.b, true, 'destroy');
|
||||||
const list = await method({
|
const list = await method({
|
||||||
scope: request.params.scope,
|
scope: request.params.scope,
|
||||||
where,
|
where,
|
||||||
|
@ -79,10 +79,9 @@ export const destroy = (server, a, b, names) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const method = getMethod(base, names.b, false);
|
const method = getMethod(base, names.b, false, 'destroy');
|
||||||
|
|
||||||
const instance = await method({ where, include });
|
const instance = await method({ where, include });
|
||||||
await instance.destroy();
|
|
||||||
|
|
||||||
reply(instance);
|
reply(instance);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user