refactor(db): migrate app pages and APIs from Prisma facade to Drizzle (2)
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
7c39aef5d9
commit
2cd0863cb8
40 files changed
+1069
-726
No files matched your search
@@ -1,8 +1,9 @@
|
||||
import { count, desc } from "drizzle-orm";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { db, EmulatorErrors } from "@/lib/db";
|
||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export default async function EmulatorErrorsPage({
|
||||
searchParams,
|
||||
@@ -19,15 +20,17 @@ export default async function EmulatorErrorsPage({
|
||||
const page = Math.max(1, Number(params.page) || 1);
|
||||
const perPage = 50;
|
||||
|
||||
const [errors, total] = await Promise.all([
|
||||
prisma.emulatorErrors.findMany({
|
||||
orderBy: { id: "desc" },
|
||||
skip: (page - 1) * perPage,
|
||||
take: perPage,
|
||||
}),
|
||||
prisma.emulatorErrors.count(),
|
||||
const [errors, totalRows] = await Promise.all([
|
||||
db
|
||||
.select()
|
||||
.from(EmulatorErrors)
|
||||
.orderBy(desc(EmulatorErrors.id))
|
||||
.limit(perPage)
|
||||
.offset((page - 1) * perPage),
|
||||
db.select({ total: count() }).from(EmulatorErrors),
|
||||
]);
|
||||
|
||||
const total = Number(totalRows[0]?.total ?? 0);
|
||||
const lastPage = Math.ceil(total / perPage);
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user