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,8 +1,9 @@
|
||||
import { and, desc, eq, gt, or } from "drizzle-orm";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { ContentCard } from "@/components/public/ui";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { activeBanWhere, unixNow } from "@/lib/bans";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { unixNow } from "@/lib/bans";
|
||||
import { Ban, db } from "@/lib/db";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -16,14 +17,21 @@ export default async function BannedPage() {
|
||||
let hasBan = false;
|
||||
if (session?.user?.id) {
|
||||
try {
|
||||
const ban = await prisma.ban.findFirst({
|
||||
where: {
|
||||
userId: Number(session.user.id),
|
||||
...activeBanWhere(unixNow()),
|
||||
},
|
||||
orderBy: { timestamp: "desc" },
|
||||
select: { banReason: true, banExpire: true },
|
||||
});
|
||||
const now = unixNow();
|
||||
const [ban] = await db
|
||||
.select({
|
||||
banReason: Ban.banReason,
|
||||
banExpire: Ban.banExpire,
|
||||
})
|
||||
.from(Ban)
|
||||
.where(
|
||||
and(
|
||||
eq(Ban.userId, Number(session.user.id)),
|
||||
or(eq(Ban.banExpire, 0), gt(Ban.banExpire, now)),
|
||||
),
|
||||
)
|
||||
.orderBy(desc(Ban.timestamp))
|
||||
.limit(1);
|
||||
if (ban) {
|
||||
hasBan = true;
|
||||
reason = ban.banReason;
|
||||
|
||||
Reference in new issue
Block a user