From e6dd2c6e6ee62b9179d014bfae159f2f4da33f2f Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:16:40 +0700 Subject: [PATCH] feat: scope type by productGroupId --- src/controllers/product/type-controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/product/type-controller.ts b/src/controllers/product/type-controller.ts index c450cd5..9f02628 100644 --- a/src/controllers/product/type-controller.ts +++ b/src/controllers/product/type-controller.ts @@ -43,8 +43,9 @@ export class ProductType extends Controller { } @Get() - async getProductType(@Query() query: string = "") { + async getProductType(@Query() query: string = "", @Query() productGroupId?: string) { const where = { + AND: { productGroupId }, OR: [{ name: { contains: query } }, { detail: { contains: query } }], } satisfies Prisma.ProductTypeWhereInput; const result = prisma.productType.findMany({ orderBy: { createdAt: "asc" }, where });