refactor(db): migrate app pages and APIs from Prisma facade to Drizzle (4)
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
580972c0a0
commit
9aa4f331bf
40 files changed
+1259
-927
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { inArray } from "drizzle-orm";
|
||||
import { withAdmin } from "@/lib/api-handler";
|
||||
import { db, ItemsBase } from "@/lib/db";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { logAudit } from "@/lib/services/audit";
|
||||
import {
|
||||
cloneSingleFurni,
|
||||
@@ -51,11 +52,10 @@ export const POST = withAdmin(
|
||||
const classnames = entries.map((e) => e.classname);
|
||||
if (classnames.length === 0) continue;
|
||||
|
||||
const placeholders = classnames.map(() => "?").join(",");
|
||||
const rows = await prisma.$queryRawUnsafe<Array<{ item_name: string }>>(
|
||||
`SELECT item_name FROM items_base WHERE item_name IN (${placeholders})`,
|
||||
...classnames,
|
||||
);
|
||||
const rows = await db
|
||||
.select({ item_name: ItemsBase.itemName })
|
||||
.from(ItemsBase)
|
||||
.where(inArray(ItemsBase.itemName, classnames));
|
||||
const have = new Set(rows.map((r) => r.item_name));
|
||||
|
||||
for (const entry of entries) {
|
||||
|
||||
Reference in new issue
Block a user