From 788cef166496048d1d0b1722c264de3b7aed79d0 Mon Sep 17 00:00:00 2001 From: Jeremy Morrell Date: Sun, 21 Sep 2025 09:13:59 -0700 Subject: [PATCH] Proposal for improving types with query method --- packages/storage/src/index.ts | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/storage/src/index.ts b/packages/storage/src/index.ts index 65c522e..b02361d 100644 --- a/packages/storage/src/index.ts +++ b/packages/storage/src/index.ts @@ -152,23 +152,14 @@ export class Storage { * @param opts - Options containing the SQL query, parameters, and result format preference * @returns Promise resolving to either raw query results or formatted array */ - private async query(sql: string, params?: unknown[], isRaw?: boolean) { + private async query>( + sql: string, params?: unknown[] + ) { // Now proceed with executing the query - const cursor = await this.executeRawQuery({ sql, params }) - if (!cursor) return [] - - if (isRaw) { - return { - columns: cursor.columnNames, - rows: Array.from(cursor.raw()), - meta: { - rows_read: cursor.rowsRead, - rows_written: cursor.rowsWritten, - }, - } - } + const cursor = await this.executeRawQuery({ sql, params }); + if (!cursor) return [] as T[]; - return cursor.toArray() + return cursor.toArray() as T[]; } async runMigrations() {