mirror of
https://github.com/saltbo/zpan.git
synced 2026-10-31 02:41:33 +08:00
Replace all db.all(sql`...`) / db.run(sql`...`) calls with Drizzle's type-safe query builder (select/insert/update/delete). Schema changes now trigger TypeScript errors in queries, and column name typos are caught at compile time. - Unify Database type to BaseSQLiteDatabase for query builder compat - Derive Matter/Storage types from schema via $inferSelect - Use inArray() instead of manual sql.join() for IN clauses - Net -90 lines across 9 files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
15 lines
551 B
TypeScript
15 lines
551 B
TypeScript
import type { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core'
|
|
import type * as authSchema from '../db/auth-schema'
|
|
import type * as appSchema from '../db/schema'
|
|
|
|
type FullSchema = typeof appSchema & typeof authSchema
|
|
|
|
// Use base type to unify BetterSQLite3 (sync) and D1 (async) drivers
|
|
// biome-ignore lint/suspicious/noExplicitAny: Drizzle drivers differ in result kind and run result types
|
|
export type Database = BaseSQLiteDatabase<any, any, FullSchema>
|
|
|
|
export interface Platform {
|
|
db: Database
|
|
getEnv(key: string): string | undefined
|
|
}
|