feat: scope type by productGroupId

This commit is contained in:
Methapon2001 2024-06-12 13:16:40 +07:00
parent 96f49ab12c
commit e6dd2c6e6e

View file

@ -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 });