@matrixai/db
Advanced tools
Comparing version 3.3.1 to 3.3.2
@@ -133,3 +133,3 @@ "use strict"; | ||
catch (e) { | ||
await tran.rollback(); | ||
await tran.rollback(e); | ||
throw e; | ||
@@ -140,3 +140,3 @@ } | ||
else { | ||
await tran.rollback(); | ||
await tran.rollback(e); | ||
} | ||
@@ -143,0 +143,0 @@ } |
@@ -44,3 +44,4 @@ /// <reference types="node" /> | ||
protected _callbacksSuccess: Array<() => any>; | ||
protected _callbacksFailure: Array<() => any>; | ||
protected _callbacksFailure: Array<(e?: Error) => any>; | ||
protected _callbacksFinally: Array<(e?: Error) => any>; | ||
protected _committed: boolean; | ||
@@ -77,7 +78,8 @@ protected _rollbacked: boolean; | ||
queueSuccess(f: () => any): void; | ||
queueFailure(f: () => any): void; | ||
queueFailure(f: (e?: Error) => any): void; | ||
queueFinally(f: (e?: Error) => any): void; | ||
commit(): Promise<void>; | ||
rollback(): Promise<void>; | ||
rollback(e?: Error): Promise<void>; | ||
finalize(): Promise<void>; | ||
} | ||
export default DBTransaction; |
@@ -39,2 +39,3 @@ "use strict"; | ||
this._callbacksFailure = []; | ||
this._callbacksFinally = []; | ||
this._committed = false; | ||
@@ -282,2 +283,5 @@ this._rollbacked = false; | ||
} | ||
queueFinally(f) { | ||
this._callbacksFinally.push(f); | ||
} | ||
async commit() { | ||
@@ -299,3 +303,3 @@ if (this._rollbacked) { | ||
} | ||
async rollback() { | ||
async rollback(e) { | ||
if (this._committed) { | ||
@@ -309,4 +313,7 @@ throw new errors.ErrorDBTransactionCommitted(); | ||
for (const f of this._callbacksFailure) { | ||
await f(); | ||
await f(e); | ||
} | ||
for (const f of this._callbacksFinally) { | ||
await f(e); | ||
} | ||
} | ||
@@ -323,2 +330,5 @@ async finalize() { | ||
} | ||
for (const f of this._callbacksFinally) { | ||
await f(); | ||
} | ||
} | ||
@@ -355,2 +365,5 @@ }; | ||
CreateDestroy_1.ready(new errors.ErrorDBTransactionDestroyed()) | ||
], DBTransaction.prototype, "queueFinally", null); | ||
__decorate([ | ||
CreateDestroy_1.ready(new errors.ErrorDBTransactionDestroyed()) | ||
], DBTransaction.prototype, "commit", null); | ||
@@ -357,0 +370,0 @@ __decorate([ |
{ | ||
"name": "@matrixai/db", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"author": "Roger Qiu", | ||
@@ -5,0 +5,0 @@ "description": "DB", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105808
1623