File tree Expand file tree Collapse file tree 2 files changed +139
-151
lines changed Expand file tree Collapse file tree 2 files changed +139
-151
lines changed Original file line number Diff line number Diff line change @@ -146,37 +146,37 @@ class DB {
146
146
delete this . workerManager ;
147
147
}
148
148
149
- // @ready (new errors.ErrorDBNotRunning())
150
- // public transaction(): ResourceAcquire<DBTransaction> {
151
- // return async () => {
152
- // const transactionId = this.transactionCounter++;
153
- // const tran = await DBTransaction.createTransaction({
154
- // db: this,
155
- // transactionId,
156
- // logger: this.logger,
157
- // });
158
- // return [
159
- // async (e?: Error) => {
160
- // try {
161
- // if (e == null) {
162
- // try {
163
- // await tran.commit();
164
- // } catch (e) {
165
- // await tran.rollback();
166
- // throw e;
167
- // }
168
- // await tran.finalize();
169
- // } else {
170
- // await tran.rollback();
171
- // }
172
- // } finally {
173
- // await tran.destroy();
174
- // }
175
- // },
176
- // tran,
177
- // ];
178
- // };
179
- // }
149
+ @ready ( new errors . ErrorDBNotRunning ( ) )
150
+ public transaction ( ) : ResourceAcquire < DBTransaction > {
151
+ return async ( ) => {
152
+ const transactionId = this . transactionCounter ++ ;
153
+ const tran = await DBTransaction . createTransaction ( {
154
+ db : this ,
155
+ transactionId,
156
+ logger : this . logger ,
157
+ } ) ;
158
+ return [
159
+ async ( e ?: Error ) => {
160
+ try {
161
+ if ( e == null ) {
162
+ try {
163
+ await tran . commit ( ) ;
164
+ } catch ( e ) {
165
+ await tran . rollback ( ) ;
166
+ throw e ;
167
+ }
168
+ await tran . finalize ( ) ;
169
+ } else {
170
+ await tran . rollback ( ) ;
171
+ }
172
+ } finally {
173
+ await tran . destroy ( ) ;
174
+ }
175
+ } ,
176
+ tran ,
177
+ ] ;
178
+ } ;
179
+ }
180
180
181
181
/**
182
182
* Gets a value from the DB
You can’t perform that action at this time.
0 commit comments