Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions packages/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T = Record<string, string | number | boolean | null>>(
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() {
Expand Down