forked from jsnbuchanan/crowd-funder-for-time-pwa
refactor: add strict typing to core database methods in PlatformServiceMixin
- Replace all `any` types in $db, $exec, $one, $query, $first, and $contacts with proper interfaces: - Use QueryExecResult and DatabaseExecResult for raw database operations - Use Contact[] for contact queries - Add generics for mapped query results - Update PlatformService and database interfaces to match new types - Remove unused type imports and fix linter errors - Reduces risk of runtime errors and improves type safety for all database access
This commit is contained in:
@@ -5,11 +5,23 @@ export interface QueryExecResult {
|
||||
values: Array<Array<SqlValue>>;
|
||||
}
|
||||
|
||||
export interface DatabaseExecResult {
|
||||
changes: number;
|
||||
lastId?: number;
|
||||
}
|
||||
|
||||
export interface DatabaseService {
|
||||
initialize(): Promise<void>;
|
||||
query(sql: string, params?: unknown[]): Promise<QueryExecResult[]>;
|
||||
run(
|
||||
sql: string,
|
||||
params?: unknown[],
|
||||
): Promise<{ changes: number; lastId?: number }>;
|
||||
run(sql: string, params?: unknown[]): Promise<DatabaseExecResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic database result type for mapped query results
|
||||
*/
|
||||
export type DatabaseResult<T = Record<string, unknown>> = T;
|
||||
|
||||
/**
|
||||
* Database query result that can be either a single result or an array
|
||||
*/
|
||||
export type DatabaseQueryResult<T = Record<string, unknown>> = T | T[] | null;
|
||||
|
||||
Reference in New Issue
Block a user