From 193e35e31cd2543d04691491b23a70049c2055af Mon Sep 17 00:00:00 2001 From: Dallas Hoffman Date: Sat, 20 Jul 2024 16:59:12 -0400 Subject: [PATCH] Add type parameter to transaction/batch --- src/client.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/client.ts b/src/client.ts index 597bad8..992bf6c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -198,21 +198,22 @@ export class SQLocal { return resultRecords as T[]; }; - transaction = async ( + transaction = async >( passStatements: (sql: typeof sqlTag) => Statement[] - ): Promise[][]> => { + ): Promise => { const statements = passStatements(sqlTag); const data = await this.execBatch(statements); return data.map(({ rows, columns }) => { - return convertRowsToObjects(rows, columns); + const resultRecords = convertRowsToObjects(rows, columns); + return resultRecords as T[]; }); }; - batch = async ( + batch = async >( passStatements: (sql: typeof sqlTag) => Statement[] - ): Promise[][]> => { - return await this.transaction(passStatements); + ): Promise => { + return await this.transaction(passStatements); }; createCallbackFunction = async (