fix: total count bigint cannot be serialize

This commit is contained in:
Methapon2001 2024-06-25 09:30:08 +07:00
parent acec110c51
commit c79851d074

View file

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