refactor: relation

This commit is contained in:
Methapon Metanipat 2024-09-30 09:41:54 +07:00
parent 5ccd8909d5
commit e3464c4891

View file

@ -128,15 +128,13 @@ export class ProductGroup extends Controller {
@Security("keycloak") @Security("keycloak")
async getProductGroupById(@Path() groupId: string) { async getProductGroupById(@Path() groupId: string) {
const record = await prisma.productGroup.findFirst({ const record = await prisma.productGroup.findFirst({
include: {
registeredBranch: true,
},
where: { id: groupId }, where: { id: groupId },
}); });
if (!record) if (!record) throw notFoundError("Product Group");
throw new HttpError(
HttpStatus.NOT_FOUND,
"Product group cannot be found.",
"productGroupNotFound",
);
return record; return record;
} }