diff --git a/packages/core/database/lib/index.d.ts b/packages/core/database/lib/index.d.ts index 552ae8f02a..146b92536a 100644 --- a/packages/core/database/lib/index.d.ts +++ b/packages/core/database/lib/index.d.ts @@ -168,7 +168,7 @@ export interface Database { trx: Knex.Transaction; rollback: () => Promise; commit: () => Promise; - }) => Promise + }) => Promise ): | Promise | { get: () => Knex.Transaction; rollback: () => Promise; commit: () => Promise }; diff --git a/packages/core/database/lib/index.js b/packages/core/database/lib/index.js index 1ed94d068e..733f9ff526 100644 --- a/packages/core/database/lib/index.js +++ b/packages/core/database/lib/index.js @@ -76,9 +76,10 @@ class Database { }; } - return transactionCtx.run({ trx, commit, rollback }, async () => { + return transactionCtx.run(trx, async () => { try { - const res = await cb(trx); + const callbackParams = { trx, commit, rollback }; + const res = await cb(callbackParams); await commit(); return res; } catch (error) {