From 8a05493bc8775dfd3427b9b39926390992e30a71 Mon Sep 17 00:00:00 2001 From: kirillgroshkov Date: Thu, 18 Jan 2024 11:45:00 +0100 Subject: [PATCH] fix: allow readOnly in CommonDao.runInTransaction --- src/commondao/common.dao.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/commondao/common.dao.ts b/src/commondao/common.dao.ts index 564e8b1..d269c59 100644 --- a/src/commondao/common.dao.ts +++ b/src/commondao/common.dao.ts @@ -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, @@ -1331,7 +1337,10 @@ export class CommonDao< await this.cfg.db.ping() } - async runInTransaction(fn: CommonDaoTransactionFn): Promise { + async runInTransaction( + fn: CommonDaoTransactionFn, + opt?: CommonDBTransactionOptions, + ): Promise { await this.cfg.db.runInTransaction(async tx => { const daoTx = new CommonDaoTransaction(tx, this.cfg.logger!) @@ -1341,7 +1350,7 @@ export class CommonDao< await daoTx.rollback() throw err } - }) + }, opt) } protected logResult(started: number, op: string, res: any, table: string): void {