mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 07:10:11 +00:00
apply fixes:
- fix callback return type - fix callback params
This commit is contained in:
parent
81f4a931a9
commit
f0dbb4be31
2
packages/core/database/lib/index.d.ts
vendored
2
packages/core/database/lib/index.d.ts
vendored
@ -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> };
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user