fix: total count bigint cannot be serialize
This commit is contained in:
parent
acec110c51
commit
c79851d074
1 changed files with 4 additions and 4 deletions
|
|
@ -66,15 +66,15 @@ export class ProductServiceController extends Controller {
|
||||||
${and.length > 0 ? Prisma.join(and, " AND ", "(", ")") : Prisma.empty}
|
${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" }))[]>`
|
prisma.$queryRaw<((Product & { type: "product" }) | (Service & { type: "service" }))[]>`
|
||||||
SELECT * FROM (${union}) AS "ProductService"
|
SELECT * FROM (${union}) AS "ProductService"
|
||||||
${where}
|
${where}
|
||||||
ORDER BY "ProductService"."statusOrder" ASC, "ProductService"."createdAt" ASC
|
ORDER BY "ProductService"."statusOrder" ASC, "ProductService"."createdAt" ASC
|
||||||
LIMIT ${pageSize} OFFSET ${(page - 1) * pageSize}
|
LIMIT ${pageSize} OFFSET ${(page - 1) * pageSize}
|
||||||
`,
|
`,
|
||||||
prisma.$queryRaw<{ total: number }>`
|
prisma.$queryRaw<[{ total: number }]>`
|
||||||
SELECT COUNT( * ) AS "total" FROM (${union}) as "ProductService"
|
SELECT COUNT(*) AS "total" FROM (${union}) as "ProductService"
|
||||||
${where}
|
${where}
|
||||||
`,
|
`,
|
||||||
]);
|
]);
|
||||||
|
|
@ -82,7 +82,7 @@ export class ProductServiceController extends Controller {
|
||||||
result,
|
result,
|
||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
total,
|
total: +String(total),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue