refactor(db): 适配 drizzle-orm 0.x API 并引入 drizzle-zod

drizzle-orm 从 1.0 beta 降级到 0.45 后,1.0 的 defineRelations、drizzle-orm/zod
子路径以及 RQB v2 的 orderBy 对象语法均不可用。改用 schema 作为 drizzle()
入参、从独立的 drizzle-zod 包导入 schema 生成器,并将 orderBy 改回 0.x 的
回调写法。同时删除因降级而失效的旧迁移。
This commit is contained in:
2026-04-24 20:08:41 +08:00
parent f9847e6f6e
commit 75c77159b4
8 changed files with 8 additions and 103 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import { todoTable } from '@/server/db/schema'
export const list = os.todo.list.use(db).handler(async ({ context }) => {
const todos = await context.db.query.todoTable.findMany({
orderBy: { createdAt: 'desc' },
orderBy: (table, { desc }) => desc(table.createdAt),
})
return todos
})