Skip to content

Commit d2141b7

Browse files
committed
WIP
1 parent b11060a commit d2141b7

File tree

2 files changed

+139
-151
lines changed

2 files changed

+139
-151
lines changed

src/DB.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -146,37 +146,37 @@ class DB {
146146
delete this.workerManager;
147147
}
148148

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+
}
180180

181181
/**
182182
* Gets a value from the DB

0 commit comments

Comments
 (0)