Repositorio para llevar el registro de operaciones a objenious

This commit is contained in:
2026-02-04 15:28:33 +01:00
parent 6171959ce6
commit 5e99ea084a
12 changed files with 178 additions and 8 deletions

View File

@@ -1,3 +1,6 @@
/**
* Result<Error,Data>
*/
export type Result<E, D> = {
error: E | undefined,
data: D | undefined

View File

@@ -1,6 +1,6 @@
import { Pool, QueryResult, QueryResultRow } from "pg";
export class postgreClient {
export class PgClient {
private pgPool: Pool;
constructor(args: {
@@ -9,13 +9,17 @@ export class postgreClient {
this.pgPool = args.pool
}
public connect() {
return this.pgPool.connect()
}
/**
* Wrapper para ejecutar consultas con tipado fuerte.
* T es el formato de la respusta.
* @param text - La consulta SQL (ej. 'SELECT * FROM users WHERE id = $1')
* @param params - Los valores para los placeholders $1, $2, etc.
*/
public async postgreQuery<T extends QueryResultRow = any>(
public async query<T extends QueryResultRow = any>(
text: string,
params?: any[]
): Promise<QueryResult<T>> {