Skip to content

Commit

Permalink
fix: allow readOnly in CommonDao.runInTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jan 18, 2024
1 parent 2ec161a commit 8a05493
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/commondao/common.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ import {
writableVoid,
} from '@naturalcycles/nodejs-lib'
import { DBLibError } from '../cnst'
import { DBModelType, DBPatch, DBTransaction, RunQueryResult } from '../db.model'
import {
CommonDBTransactionOptions,
DBModelType,
DBPatch,
DBTransaction,
RunQueryResult,
} from '../db.model'
import { DBQuery, RunnableDBQuery } from '../query/dbQuery'
import {
CommonDaoCfg,
Expand Down Expand Up @@ -1331,7 +1337,10 @@ export class CommonDao<
await this.cfg.db.ping()
}

async runInTransaction(fn: CommonDaoTransactionFn): Promise<void> {
async runInTransaction(
fn: CommonDaoTransactionFn,
opt?: CommonDBTransactionOptions,
): Promise<void> {
await this.cfg.db.runInTransaction(async tx => {
const daoTx = new CommonDaoTransaction(tx, this.cfg.logger!)

Expand All @@ -1341,7 +1350,7 @@ export class CommonDao<
await daoTx.rollback()
throw err
}
})
}, opt)
}

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

0 comments on commit 8a05493

Please sign in to comment.