From 1daa68e03e57d57f1157defd5afb7a3569925a67 Mon Sep 17 00:00:00 2001 From: Joey Baker Date: Thu, 27 Oct 2016 21:03:57 -0700 Subject: [PATCH] Fix(crud) destroyScope sends 404 when not found --- src/crud.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/crud.js b/src/crud.js index be9bcd1..32cc61a 100644 --- a/src/crud.js +++ b/src/crud.js @@ -309,6 +309,8 @@ export const destroyScope = ({ server, model, prefix = '/', config }) => { 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())); const listAsJSON = list.map((item) => item.toJSON());