chore(server): resolve db type

This commit is contained in:
RainbowBird
2026-03-28 02:25:44 +08:00
committed by RainbowBird
parent 0aa90bd713
commit eab6772a89
2 changed files with 4 additions and 5 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ import { vi } from 'vitest'
*
* @see https://github.com/drizzle-team/drizzle-orm/issues/4205#issuecomment-2747745901
*/
export async function mockDB(schema: Record<string, any>): Promise<Database<typeof schema>> {
export async function mockDB(schema: Record<string, any>): Promise<Database> {
// Hack: dynamic require to bypass ESM/CJS issues with drizzle-kit in Vitest
const { createRequire } = await vi.importActual<typeof import('node:module')>('node:module')
const require = createRequire(import.meta.url)
@@ -23,7 +23,7 @@ export async function mockDB(schema: Record<string, any>): Promise<Database<type
})
// Create Drizzle instance without running full migrations
const db = drizzle(client, { schema }) as unknown as Database<typeof schema>
const db = drizzle(client, { schema }) as unknown as Database
// Enable pgvector type in this in-memory database before applying schema
// This mirrors the production pglite initialization which runs:
+2 -3
View File
@@ -1,5 +1,4 @@
import type * as fullSchema from '../schemas'
import type { Database } from './db'
import type { Database } from '../libs/db'
import { and, eq, gte, sql } from 'drizzle-orm'
@@ -7,7 +6,7 @@ import { createPaymentRequiredError } from '../utils/error'
import * as schema from '../schemas/flux'
export function createFluxService(db: Database<typeof fullSchema>) {
export function createFluxService(db: Database) {
return {
async getFlux(userId: string) {
let record = await db.query.userFlux.findFirst({