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,10 +1,11 @@
|
||||
import { asc, eq, ne } from "drizzle-orm";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { ContentCard } from "@/components/public/ui";
|
||||
import { SanitizedHtml } from "@/components/shared/sanitized-html";
|
||||
import { db, WebsiteHelpCenterCategories } from "@/lib/db";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { sanitize } from "@/lib/sanitize";
|
||||
|
||||
export const revalidate = 300;
|
||||
@@ -54,21 +55,23 @@ export default async function HelpCategoryPage({
|
||||
|
||||
let cat: HelpCategory | null = null;
|
||||
try {
|
||||
cat = await prisma.websiteHelpCenterCategories.findUnique({
|
||||
where: { id: categoryId },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
content: true,
|
||||
position: true,
|
||||
imageUrl: true,
|
||||
buttonText: true,
|
||||
buttonUrl: true,
|
||||
buttonColor: true,
|
||||
buttonBorderColor: true,
|
||||
smallBox: true,
|
||||
},
|
||||
});
|
||||
const [row] = await db
|
||||
.select({
|
||||
id: WebsiteHelpCenterCategories.id,
|
||||
name: WebsiteHelpCenterCategories.name,
|
||||
content: WebsiteHelpCenterCategories.content,
|
||||
position: WebsiteHelpCenterCategories.position,
|
||||
imageUrl: WebsiteHelpCenterCategories.imageUrl,
|
||||
buttonText: WebsiteHelpCenterCategories.buttonText,
|
||||
buttonUrl: WebsiteHelpCenterCategories.buttonUrl,
|
||||
buttonColor: WebsiteHelpCenterCategories.buttonColor,
|
||||
buttonBorderColor: WebsiteHelpCenterCategories.buttonBorderColor,
|
||||
smallBox: WebsiteHelpCenterCategories.smallBox,
|
||||
})
|
||||
.from(WebsiteHelpCenterCategories)
|
||||
.where(eq(WebsiteHelpCenterCategories.id, categoryId))
|
||||
.limit(1);
|
||||
cat = row ?? null;
|
||||
} catch {
|
||||
cat = null;
|
||||
}
|
||||
@@ -81,12 +84,16 @@ export default async function HelpCategoryPage({
|
||||
// query: a DB hiccup degrades this list to empty rather than 500-ing.
|
||||
let siblings: HelpCategoryLink[] = [];
|
||||
try {
|
||||
siblings = await prisma.websiteHelpCenterCategories.findMany({
|
||||
where: { id: { not: categoryId } },
|
||||
orderBy: { position: "asc" },
|
||||
select: { id: true, name: true, position: true },
|
||||
take: 50,
|
||||
});
|
||||
siblings = await db
|
||||
.select({
|
||||
id: WebsiteHelpCenterCategories.id,
|
||||
name: WebsiteHelpCenterCategories.name,
|
||||
position: WebsiteHelpCenterCategories.position,
|
||||
})
|
||||
.from(WebsiteHelpCenterCategories)
|
||||
.where(ne(WebsiteHelpCenterCategories.id, categoryId))
|
||||
.orderBy(asc(WebsiteHelpCenterCategories.position))
|
||||
.limit(50);
|
||||
} catch {
|
||||
siblings = [];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user