From 32a539c3d987272c3f2a2e334524269e646d21ac Mon Sep 17 00:00:00 2001 From: Joey Baker Date: Sun, 4 Sep 2016 15:35:19 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20(crud)=20`update`:=20`findOne`=20?= =?UTF-8?q?=E2=86=92=20`findById`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit b/c `findById` uses an index to lookup, and should be fast. --- src/crud.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/crud.js b/src/crud.js index 66d0867..98fae67 100644 --- a/src/crud.js +++ b/src/crud.js @@ -243,11 +243,7 @@ export const update = ({ server, model, prefix = '/', config }) => { @error async handler(request, reply) { const { id } = request.params; - const instance = await model.findOne({ - where: { - id, - }, - }); + const instance = await model.findById(id); if (!instance) return void reply(notFound(`${id} not found.`));