From 990a4687fdb3fc5a0ed9e8be974fbc520c62fdf3 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Mon, 25 Nov 2024 15:14:42 +0700 Subject: [PATCH] fix: error when no ids --- src/controllers/04-service-controller.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/controllers/04-service-controller.ts b/src/controllers/04-service-controller.ts index a31d744..b76c110 100644 --- a/src/controllers/04-service-controller.ts +++ b/src/controllers/04-service-controller.ts @@ -402,11 +402,9 @@ export class ServiceController extends Controller { ...payload, statusOrder: +(payload.status === "INACTIVE"), work: { - deleteMany: { - id: work?.some((v) => !!v.id) - ? { notIn: work.flatMap((v) => (!!v.id ? v.id : [])) } - : undefined, - }, + deleteMany: work?.some((v) => !!v.id) + ? { id: { notIn: work.flatMap((v) => (!!v.id ? v.id : [])) } } + : {}, upsert: (work || []).map((w, wIdx) => ({ where: { id: w.id }, create: {