refactor(db): migrate app pages and APIs from Prisma facade to Drizzle
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
53b350057d
commit
7c39aef5d9
40 files changed
+1124
-692
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { desc, eq } from "drizzle-orm";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
@@ -5,8 +6,8 @@ import type { CSSProperties } from "react";
|
||||
import { createTicket } from "@/actions/help-tickets";
|
||||
import { ContentCard, EmptyState, StatBlock } from "@/components/public/ui";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { db, WebsiteHelpCenterTickets } from "@/lib/db";
|
||||
import { formatDate } from "@/lib/format-date";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -41,15 +42,14 @@ export default async function HelpTicketsPage({
|
||||
|
||||
const userId = Number(session.user.id);
|
||||
|
||||
let tickets: Awaited<
|
||||
ReturnType<typeof prisma.websiteHelpCenterTickets.findMany>
|
||||
> = [];
|
||||
let tickets: (typeof WebsiteHelpCenterTickets.$inferSelect)[] = [];
|
||||
try {
|
||||
tickets = await prisma.websiteHelpCenterTickets.findMany({
|
||||
where: { userId },
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 100,
|
||||
});
|
||||
tickets = await db
|
||||
.select()
|
||||
.from(WebsiteHelpCenterTickets)
|
||||
.where(eq(WebsiteHelpCenterTickets.userId, userId))
|
||||
.orderBy(desc(WebsiteHelpCenterTickets.createdAt))
|
||||
.limit(100);
|
||||
} catch {
|
||||
tickets = [];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user