@naturalcycles/db-lib 9.2.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Transform } from 'node:stream';
|
|
3
3
|
import { AnyObject, AsyncMapper, CommonLogger, JsonSchemaObject, JsonSchemaRootObject, ObjectWithId, Saved, UnixTimestampMillisNumber, Unsaved, ZodSchema } from '@naturalcycles/js-lib';
|
|
4
4
|
import { AjvSchema, ObjectSchema, ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
5
|
-
import { DBModelType, DBPatch, DBTransaction, RunQueryResult } from '../db.model';
|
|
5
|
+
import { CommonDBTransactionOptions, DBModelType, DBPatch, DBTransaction, RunQueryResult } from '../db.model';
|
|
6
6
|
import { DBQuery, RunnableDBQuery } from '../query/dbQuery';
|
|
7
7
|
import { CommonDaoCfg, CommonDaoCreateOptions, CommonDaoOptions, CommonDaoSaveBatchOptions, CommonDaoSaveOptions, CommonDaoStreamDeleteOptions, CommonDaoStreamForEachOptions, CommonDaoStreamOptions, CommonDaoStreamSaveOptions } from './common.dao.model';
|
|
8
8
|
/**
|
|
@@ -169,7 +169,7 @@ export declare class CommonDao<BM extends Partial<ObjectWithId>, DBM extends Obj
|
|
|
169
169
|
* Proxy to this.cfg.db.ping
|
|
170
170
|
*/
|
|
171
171
|
ping(): Promise<void>;
|
|
172
|
-
runInTransaction(fn: CommonDaoTransactionFn): Promise<void>;
|
|
172
|
+
runInTransaction(fn: CommonDaoTransactionFn, opt?: CommonDBTransactionOptions): Promise<void>;
|
|
173
173
|
protected logResult(started: number, op: string, res: any, table: string): void;
|
|
174
174
|
protected logSaveResult(started: number, op: string, table: string): void;
|
|
175
175
|
protected logStarted(op: string, table: string, force?: boolean): UnixTimestampMillisNumber;
|
|
@@ -991,7 +991,7 @@ class CommonDao {
|
|
|
991
991
|
async ping() {
|
|
992
992
|
await this.cfg.db.ping();
|
|
993
993
|
}
|
|
994
|
-
async runInTransaction(fn) {
|
|
994
|
+
async runInTransaction(fn, opt) {
|
|
995
995
|
await this.cfg.db.runInTransaction(async (tx) => {
|
|
996
996
|
const daoTx = new CommonDaoTransaction(tx, this.cfg.logger);
|
|
997
997
|
try {
|
|
@@ -1001,7 +1001,7 @@ class CommonDao {
|
|
|
1001
1001
|
await daoTx.rollback();
|
|
1002
1002
|
throw err;
|
|
1003
1003
|
}
|
|
1004
|
-
});
|
|
1004
|
+
}, opt);
|
|
1005
1005
|
}
|
|
1006
1006
|
logResult(started, op, res, table) {
|
|
1007
1007
|
if (!this.cfg.logLevel)
|
package/package.json
CHANGED
|
@@ -43,7 +43,13 @@ import {
|
|
|
43
43
|
writableVoid,
|
|
44
44
|
} from '@naturalcycles/nodejs-lib'
|
|
45
45
|
import { DBLibError } from '../cnst'
|
|
46
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
CommonDBTransactionOptions,
|
|
48
|
+
DBModelType,
|
|
49
|
+
DBPatch,
|
|
50
|
+
DBTransaction,
|
|
51
|
+
RunQueryResult,
|
|
52
|
+
} from '../db.model'
|
|
47
53
|
import { DBQuery, RunnableDBQuery } from '../query/dbQuery'
|
|
48
54
|
import {
|
|
49
55
|
CommonDaoCfg,
|
|
@@ -1331,7 +1337,10 @@ export class CommonDao<
|
|
|
1331
1337
|
await this.cfg.db.ping()
|
|
1332
1338
|
}
|
|
1333
1339
|
|
|
1334
|
-
async runInTransaction(
|
|
1340
|
+
async runInTransaction(
|
|
1341
|
+
fn: CommonDaoTransactionFn,
|
|
1342
|
+
opt?: CommonDBTransactionOptions,
|
|
1343
|
+
): Promise<void> {
|
|
1335
1344
|
await this.cfg.db.runInTransaction(async tx => {
|
|
1336
1345
|
const daoTx = new CommonDaoTransaction(tx, this.cfg.logger!)
|
|
1337
1346
|
|
|
@@ -1341,7 +1350,7 @@ export class CommonDao<
|
|
|
1341
1350
|
await daoTx.rollback()
|
|
1342
1351
|
throw err
|
|
1343
1352
|
}
|
|
1344
|
-
})
|
|
1353
|
+
}, opt)
|
|
1345
1354
|
}
|
|
1346
1355
|
|
|
1347
1356
|
protected logResult(started: number, op: string, res: any, table: string): void {
|