From fac656ce914a37d288b50bf821253851e399e435 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Tue, 18 Aug 2020 17:26:07 -0600 Subject: [PATCH] Add ability to batch update multiple standalone items --- api/src/controllers/items.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/controllers/items.ts b/api/src/controllers/items.ts index 3dbaa1aa6e..9dc11f8596 100644 --- a/api/src/controllers/items.ts +++ b/api/src/controllers/items.ts @@ -79,7 +79,9 @@ router.patch( return res.json({ data: item || null }); } - throw new RouteNotFoundException(req.path); + const primaryKeys = await service.update(req.body); + const result = await service.readByKey(primaryKeys, req.sanitizedQuery); + return res.json({ data: result || null }); }) ); @@ -96,7 +98,6 @@ router.patch( const primaryKey = req.params.pk.includes(',') ? req.params.pk.split(',') : req.params.pk; const updatedPrimaryKey = await service.update(req.body, primaryKey as any); - const result = await service.readByKey(updatedPrimaryKey, req.sanitizedQuery); res.json({ data: result || null });