From 158162688076a131a57720afacdd3e85893ee12d Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 5 Sep 2024 14:37:39 +0700 Subject: [PATCH] feat: return relation --- src/controllers/01-branch-controller.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/controllers/01-branch-controller.ts b/src/controllers/01-branch-controller.ts index 732fb26..3cb5473 100644 --- a/src/controllers/01-branch-controller.ts +++ b/src/controllers/01-branch-controller.ts @@ -383,6 +383,7 @@ export class BranchController extends Controller { district: true, subDistrict: true, contact: true, + bank: true, createdBy: true, updatedBy: true, }, @@ -505,7 +506,15 @@ export class BranchController extends Controller { ); return await prisma.branch.update({ - include: { province: true, district: true, subDistrict: true }, + include: { + province: true, + district: true, + subDistrict: true, + contact: true, + bank: true, + createdBy: true, + updatedBy: true, + }, data: { ...rest, statusOrder: +(rest.status === "INACTIVE"), @@ -515,9 +524,7 @@ export class BranchController extends Controller { deleteMany: listDeleted.length > 0 ? { id: { in: listDeleted.map((v) => v.id) } } : undefined, upsert: bank.map((v) => ({ - where: { - id: v.id || "", - }, + where: { id: v.id || "" }, create: { ...v, id: undefined }, update: v, })),