commit 2 refactor

This commit is contained in:
Boki 2026-10-20 14:35:45 -04:00
parent 588f666943
commit 32e43c9243
310 changed files with 33318 additions and 31189 deletions

View file

@ -18,8 +18,8 @@ export class PostgreSQLQueryBuilder {
private orderByConditions: OrderByCondition[] = [];
private limitCount: number | null = null;
private offsetCount: number | null = null;
private insertValues: Record<string, any> = {};
private updateValues: Record<string, any> = {};
private insertValues: Record<string, unknown> = {};
private updateValues: Record<string, unknown> = {};
private readonly client: PostgreSQLClient;
@ -55,8 +55,8 @@ export class PostgreSQLQueryBuilder {
/**
* WHERE clause
*/
where(column: string, operator: string, value?: any): this {
this.whereConditions.push({ column, operator: operator as any, value });
where(column: string, operator: WhereCondition['operator'], value?: unknown): this {
this.whereConditions.push({ column, operator, value });
return this;
}
@ -104,7 +104,7 @@ export class PostgreSQLQueryBuilder {
/**
* VALUES for INSERT
*/
values(data: Record<string, any>): this {
values(data: Record<string, unknown>): this {
this.insertValues = data;
return this;
}
@ -121,7 +121,7 @@ export class PostgreSQLQueryBuilder {
/**
* SET for UPDATE
*/
set(data: Record<string, any>): this {
set(data: Record<string, unknown>): this {
this.updateValues = data;
return this;
}
@ -138,7 +138,7 @@ export class PostgreSQLQueryBuilder {
/**
* Build and execute the query
*/
async execute<T extends QueryResultRow = any>(): Promise<QueryResult<T>> {
async execute<T extends QueryResultRow = QueryResultRow>(): Promise<QueryResult<T>> {
const { sql, params } = this.build();
return await this.client.query<T>(sql, params);
}
@ -146,8 +146,8 @@ export class PostgreSQLQueryBuilder {
/**
* Build the SQL query
*/
build(): { sql: string; params: any[] } {
const params: any[] = [];
build(): { sql: string; params: unknown[] } {
const params: unknown[] = [];
let sql = '';
switch (this.queryType) {
@ -170,7 +170,7 @@ export class PostgreSQLQueryBuilder {
return { sql, params };
}
private buildSelectQuery(params: any[]): string {
private buildSelectQuery(params: unknown[]): string {
let sql = `SELECT ${this.selectColumns.join(', ')}`;
if (this.fromTable) {
@ -220,7 +220,7 @@ export class PostgreSQLQueryBuilder {
return sql;
}
private buildInsertQuery(params: any[]): string {
private buildInsertQuery(params: unknown[]): string {
const columns = Object.keys(this.insertValues);
const placeholders = columns.map((_, i) => `$${params.length + i + 1}`);
@ -229,7 +229,7 @@ export class PostgreSQLQueryBuilder {
return `INSERT INTO ${this.fromTable} (${columns.join(', ')}) VALUES (${placeholders.join(', ')})`;
}
private buildUpdateQuery(params: any[]): string {
private buildUpdateQuery(params: unknown[]): string {
const sets = Object.keys(this.updateValues).map((key, i) => {
return `${key} = $${params.length + i + 1}`;
});
@ -245,7 +245,7 @@ export class PostgreSQLQueryBuilder {
return sql;
}
private buildDeleteQuery(params: any[]): string {
private buildDeleteQuery(params: unknown[]): string {
let sql = `DELETE FROM ${this.fromTable}`;
if (this.whereConditions.length > 0) {
@ -255,7 +255,7 @@ export class PostgreSQLQueryBuilder {
return sql;
}
private buildWhereClause(conditions: WhereCondition[], params: any[]): string {
private buildWhereClause(conditions: WhereCondition[], params: unknown[]): string {
return conditions
.map(condition => {
if (condition.operator === 'IS NULL' || condition.operator === 'IS NOT NULL') {