refactor(db): migrate app pages and APIs from Prisma facade to Drizzle (3)
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { asc } from "drizzle-orm";
|
||||
import NextImage from "next/image";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import {
|
||||
@@ -7,8 +8,8 @@ import {
|
||||
} from "@/actions/admin-radio-extra";
|
||||
import { StatusCard } from "@/components/admin/dashboard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { db, RadioBanners } from "@/lib/db";
|
||||
import { formatDate } from "@/lib/format-date";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
type Banner = {
|
||||
id: bigint;
|
||||
@@ -28,19 +29,19 @@ export default async function AdminRadioBannersPage() {
|
||||
let dbError = false;
|
||||
|
||||
try {
|
||||
banners = await prisma.radioBanners.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
userId: true,
|
||||
imagePath: true,
|
||||
title: true,
|
||||
description: true,
|
||||
sortOrder: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
},
|
||||
orderBy: [{ sortOrder: "asc" }, { id: "asc" }],
|
||||
});
|
||||
banners = await db
|
||||
.select({
|
||||
id: RadioBanners.id,
|
||||
userId: RadioBanners.userId,
|
||||
imagePath: RadioBanners.imagePath,
|
||||
title: RadioBanners.title,
|
||||
description: RadioBanners.description,
|
||||
sortOrder: RadioBanners.sortOrder,
|
||||
isActive: RadioBanners.isActive,
|
||||
createdAt: RadioBanners.createdAt,
|
||||
})
|
||||
.from(RadioBanners)
|
||||
.orderBy(asc(RadioBanners.sortOrder), asc(RadioBanners.id));
|
||||
} catch {
|
||||
dbError = true;
|
||||
banners = [];
|
||||
|
||||
Reference in New Issue
Block a user