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,3 +1,4 @@
|
||||
import { asc } from "drizzle-orm";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import {
|
||||
@@ -6,8 +7,8 @@ import {
|
||||
updateEmailTemplate,
|
||||
} from "@/actions/admin-email-templates";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { db, EmailTemplates } from "@/lib/db";
|
||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export default async function AdminEmailTemplates() {
|
||||
const { session, permissions } = await getAdminContext();
|
||||
@@ -17,12 +18,12 @@ export default async function AdminEmailTemplates() {
|
||||
|
||||
const t = await getTranslations("pages.admin.emailTemplates");
|
||||
|
||||
let templates: Awaited<ReturnType<typeof prisma.emailTemplates.findMany>> =
|
||||
[];
|
||||
let templates: (typeof EmailTemplates.$inferSelect)[] = [];
|
||||
try {
|
||||
templates = await prisma.emailTemplates.findMany({
|
||||
orderBy: { name: "asc" },
|
||||
});
|
||||
templates = await db
|
||||
.select()
|
||||
.from(EmailTemplates)
|
||||
.orderBy(asc(EmailTemplates.name));
|
||||
} catch {
|
||||
templates = [];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user