From e3464c4891926e70b06b5c3ac69057b64c9d1c8d Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Mon, 30 Sep 2024 09:41:54 +0700 Subject: [PATCH] refactor: relation --- src/controllers/04-product-group-controller.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/controllers/04-product-group-controller.ts b/src/controllers/04-product-group-controller.ts index dfe3cd8..f1a4fe8 100644 --- a/src/controllers/04-product-group-controller.ts +++ b/src/controllers/04-product-group-controller.ts @@ -128,15 +128,13 @@ export class ProductGroup extends Controller { @Security("keycloak") async getProductGroupById(@Path() groupId: string) { const record = await prisma.productGroup.findFirst({ + include: { + registeredBranch: true, + }, where: { id: groupId }, }); - if (!record) - throw new HttpError( - HttpStatus.NOT_FOUND, - "Product group cannot be found.", - "productGroupNotFound", - ); + if (!record) throw notFoundError("Product Group"); return record; }