Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 8a05493

Browse files
fix: allow readOnly in CommonDao.runInTransaction
1 parent 2ec161a commit 8a05493

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/commondao/common.dao.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ import {
4343
writableVoid,
4444
} from '@naturalcycles/nodejs-lib'
4545
import { DBLibError } from '../cnst'
46-
import { DBModelType, DBPatch, DBTransaction, RunQueryResult } from '../db.model'
46+
import {
47+
CommonDBTransactionOptions,
48+
DBModelType,
49+
DBPatch,
50+
DBTransaction,
51+
RunQueryResult,
52+
} from '../db.model'
4753
import { DBQuery, RunnableDBQuery } from '../query/dbQuery'
4854
import {
4955
CommonDaoCfg,
@@ -1331,7 +1337,10 @@ export class CommonDao<
13311337
await this.cfg.db.ping()
13321338
}
13331339

1334-
async runInTransaction(fn: CommonDaoTransactionFn): Promise<void> {
1340+
async runInTransaction(
1341+
fn: CommonDaoTransactionFn,
1342+
opt?: CommonDBTransactionOptions,
1343+
): Promise<void> {
13351344
await this.cfg.db.runInTransaction(async tx => {
13361345
const daoTx = new CommonDaoTransaction(tx, this.cfg.logger!)
13371346

@@ -1341,7 +1350,7 @@ export class CommonDao<
13411350
await daoTx.rollback()
13421351
throw err
13431352
}
1344-
})
1353+
}, opt)
13451354
}
13461355

13471356
protected logResult(started: number, op: string, res: any, table: string): void {

0 commit comments

Comments
 (0)