Fix(crud) destroyScope sends 404 when not found

This commit is contained in:
Joey Baker 2016-10-27 21:03:57 -07:00
parent 01081db7a3
commit 1daa68e03e

View File

@ -309,6 +309,8 @@ export const destroyScope = ({ server, model, prefix = '/', config }) => {
const list = await model.scope(request.params.scope).findAll({ include, where }); const list = await model.scope(request.params.scope).findAll({ include, where });
if (!list.length) return void reply(notFound('Nothing found.'));
await Promise.all(list.map(instance => instance.destroy())); await Promise.all(list.map(instance => instance.destroy()));
const listAsJSON = list.map((item) => item.toJSON()); const listAsJSON = list.map((item) => item.toJSON());