feat: Füge Typparser für PostgreSQL hinzu, um Dezimal- und Ganzzahlen korrekt zu verarbeiten

This commit is contained in:
2025-11-23 14:06:54 +01:00
parent 32eff5ba96
commit 96591cf625

View File

@@ -1,6 +1,10 @@
import { Pool } from "pg";
import { Pool, types } from "pg"; // "types" importieren
import { config } from "./config";
types.setTypeParser(1700, (val) => parseFloat(val));
types.setTypeParser(20, (val) => parseInt(val, 10));
export const pool = new Pool({
connectionString: config.databaseUrl
});
@@ -9,4 +13,4 @@ export const pool = new Pool({
export async function query<T = any>(text: string, params?: any[]): Promise<T[]> {
const res = await pool.query(text, params);
return res.rows as T[];
}
}