fix(crud): DELETE plural
This commit is contained in:
parent
973f63640c
commit
193aec9619
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hapi-sequelize-crud",
|
||||
"version": "2.0.6",
|
||||
"version": "2.0.7",
|
||||
"description": "Hapi plugin that automatically generates RESTful API for CRUD",
|
||||
"main": "build/index.js",
|
||||
"config": {
|
||||
|
19
src/crud.js
19
src/crud.js
@ -121,6 +121,25 @@ export const destroy = (server, model) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const destroyAll = (server, model) => {
|
||||
server.route({
|
||||
method: 'DELETE',
|
||||
path: `${prefix}/${model._plural}`,
|
||||
|
||||
@error
|
||||
async handler(request, reply) {
|
||||
const include = parseInclude(request);
|
||||
const where = parseWhere(request);
|
||||
|
||||
const list = await model.findAll({ where });
|
||||
|
||||
await* list.map(instance => instance.destroy());
|
||||
|
||||
reply(list.length === 1 ? list[0] : list);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const destroyScope = (server, model) => {
|
||||
let scopes = Object.keys(model.options.scopes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user