From c7183887c9372c0881ab18930ef1395a7fd805d8 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 22 Jul 2025 10:35:48 +0700 Subject: [PATCH] fix: error create many with relation --- src/controllers/07-task-controller.ts | 40 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/controllers/07-task-controller.ts b/src/controllers/07-task-controller.ts index c9b6b9d..ba2f656 100644 --- a/src/controllers/07-task-controller.ts +++ b/src/controllers/07-task-controller.ts @@ -925,14 +925,18 @@ export class TaskActionController extends Controller { data: { requestDataStatus: RequestDataStatus.Completed }, }) .then(async (res) => { - await tx.notification.createMany({ - data: res.map((v) => ({ - title: "รายการคำขอเสร็จสิ้น / Request Complete", - detail: "รหัส / code : " + v.code + " Completed", - receiverId: v.quotation.createdByUserId, - groupReceiver: { create: { name: "document_checker" } }, - })), - }); + await Promise.all( + res.map((v) => + tx.notification.create({ + data: { + title: "สถานะใบเสนอราคาเปลี่ยนแปลง / Quotation Status Updated", + detail: "รหัส / code : " + v.code + " Completed", + receiverId: v.quotation.createdByUserId, + groupReceiver: { create: { name: "document_checker" } }, + }, + }), + ), + ); }); await tx.quotation .updateManyAndReturn({ @@ -973,14 +977,18 @@ export class TaskActionController extends Controller { }, }) .then(async (res) => { - await tx.notification.createMany({ - data: res.map((v) => ({ - title: "สถานะใบเสนอราคาเปลี่ยนแปลง / Quotation Status Updated", - detail: "รหัส / code : " + v.code + " Completed", - receiverId: v.createdByUserId, - groupReceiver: { create: { name: "document_checker" } }, - })), - }); + await Promise.all( + res.map((v) => + tx.notification.create({ + data: { + title: "สถานะใบเสนอราคาเปลี่ยนแปลง / Quotation Status Updated", + detail: "รหัส / code : " + v.code + " Completed", + receiverId: v.createdByUserId, + groupReceiver: { create: { name: "document_checker" } }, + }, + }), + ), + ); const token = await this.#getLineToken();