diff --git a/src/controllers/product-service-controller.ts b/src/controllers/product-service-controller.ts index 13585ac..c2aab92 100644 --- a/src/controllers/product-service-controller.ts +++ b/src/controllers/product-service-controller.ts @@ -66,15 +66,15 @@ export class ProductServiceController extends Controller { ${and.length > 0 ? Prisma.join(and, " AND ", "(", ")") : Prisma.empty} `; - const [result, { total }] = await prisma.$transaction([ + const [result, [{ total }]] = await prisma.$transaction([ prisma.$queryRaw<((Product & { type: "product" }) | (Service & { type: "service" }))[]>` SELECT * FROM (${union}) AS "ProductService" ${where} ORDER BY "ProductService"."statusOrder" ASC, "ProductService"."createdAt" ASC LIMIT ${pageSize} OFFSET ${(page - 1) * pageSize} `, - prisma.$queryRaw<{ total: number }>` - SELECT COUNT( * ) AS "total" FROM (${union}) as "ProductService" + prisma.$queryRaw<[{ total: number }]>` + SELECT COUNT(*) AS "total" FROM (${union}) as "ProductService" ${where} `, ]); @@ -82,7 +82,7 @@ export class ProductServiceController extends Controller { result, page, pageSize, - total, + total: +String(total), }; } }