fix: QueryResultRow-Constraint für db.query<T> unter TypeScript strict
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import { Pool } from 'pg'
|
import { Pool, type QueryResultRow } from 'pg'
|
||||||
|
|
||||||
const pool = new Pool({ connectionString: process.env.DATABASE_URL })
|
const pool = new Pool({ connectionString: process.env.DATABASE_URL })
|
||||||
|
|
||||||
export const db = {
|
export const db = {
|
||||||
execute: (sql: string) => pool.query(sql),
|
execute: (sql: string) => pool.query(sql),
|
||||||
query: <T = Record<string, unknown>>(sql: string, params: unknown[]) =>
|
query: <T extends QueryResultRow = Record<string, unknown>>(sql: string, params: unknown[]) =>
|
||||||
pool.query<T>(sql, params).then((r) => r.rows),
|
pool.query<T>(sql, params).then((r) => r.rows),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user