Skip to content

Commit

Permalink
Name type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
DallasHoff committed Jul 21, 2024
1 parent 193e35e commit 10f0b6a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ export class SQLocal {
return data;
};

sql = async <T extends Record<string, any>>(
sql = async <Result extends Record<string, any>>(
queryTemplate: TemplateStringsArray | string,
...params: unknown[]
): Promise<T[]> => {
): Promise<Result[]> => {
let statement: Statement;

if (typeof queryTemplate === 'string') {
Expand All @@ -195,25 +195,25 @@ export class SQLocal {
'all'
);
const resultRecords = convertRowsToObjects(rows, columns);
return resultRecords as T[];
return resultRecords as Result[];
};

transaction = async <T extends Record<string, any>>(
transaction = async <Result extends Record<string, any>>(
passStatements: (sql: typeof sqlTag) => Statement[]
): Promise<T[][]> => {
): Promise<Result[][]> => {
const statements = passStatements(sqlTag);
const data = await this.execBatch(statements);

return data.map(({ rows, columns }) => {
const resultRecords = convertRowsToObjects(rows, columns);
return resultRecords as T[];
return resultRecords as Result[];
});
};

batch = async <T extends Record<string, any>>(
batch = async <Result extends Record<string, any>>(
passStatements: (sql: typeof sqlTag) => Statement[]
): Promise<T[][]> => {
return await this.transaction<T>(passStatements);
): Promise<Result[][]> => {
return await this.transaction<Result>(passStatements);
};

createCallbackFunction = async (
Expand Down

0 comments on commit 10f0b6a

Please sign in to comment.