apply fixes:

- fix callback return type
- fix callback params
This commit is contained in:
Bassel 2023-01-24 14:39:24 +02:00
parent 81f4a931a9
commit f0dbb4be31
2 changed files with 4 additions and 3 deletions

View File

@ -168,7 +168,7 @@ export interface Database {
trx: Knex.Transaction; trx: Knex.Transaction;
rollback: () => Promise<void>; rollback: () => Promise<void>;
commit: () => Promise<void>; commit: () => Promise<void>;
}) => Promise<void> }) => Promise<unknown>
): ):
| Promise<unknown> | Promise<unknown>
| { get: () => Knex.Transaction; rollback: () => Promise<void>; commit: () => Promise<void> }; | { get: () => Knex.Transaction; rollback: () => Promise<void>; commit: () => Promise<void> };

View File

@ -76,9 +76,10 @@ class Database {
}; };
} }
return transactionCtx.run({ trx, commit, rollback }, async () => { return transactionCtx.run(trx, async () => {
try { try {
const res = await cb(trx); const callbackParams = { trx, commit, rollback };
const res = await cb(callbackParams);
await commit(); await commit();
return res; return res;
} catch (error) { } catch (error) {