@naturalcycles/db-lib 8.38.0 → 8.38.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.
|
@@ -410,7 +410,7 @@ class CommonDao {
|
|
|
410
410
|
}
|
|
411
411
|
async streamQueryIdsForEach(q, mapper, opt = {}) {
|
|
412
412
|
q.table = opt.table || q.table;
|
|
413
|
-
opt.errorMode
|
|
413
|
+
opt.errorMode || (opt.errorMode = js_lib_1.ErrorMode.SUPPRESS);
|
|
414
414
|
const op = `streamQueryIdsForEach(${q.pretty()})`;
|
|
415
415
|
const started = this.logStarted(op, q.table, true);
|
|
416
416
|
let count = 0;
|
|
@@ -456,8 +456,8 @@ class CommonDao {
|
|
|
456
456
|
const table = opt.table || this.cfg.table;
|
|
457
457
|
if (opt.ensureUniqueId && idWasGenerated)
|
|
458
458
|
await this.ensureUniqueId(table, dbm);
|
|
459
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
460
|
-
opt
|
|
459
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
460
|
+
opt = { ...opt, saveMethod: 'insert' };
|
|
461
461
|
}
|
|
462
462
|
const op = `save(${dbm.id})`;
|
|
463
463
|
const started = this.logSaveStarted(op, bm, table);
|
|
@@ -502,8 +502,8 @@ class CommonDao {
|
|
|
502
502
|
if (opt.ensureUniqueId && idWasGenerated)
|
|
503
503
|
await this.ensureUniqueId(table, dbm);
|
|
504
504
|
}
|
|
505
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
506
|
-
opt
|
|
505
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
506
|
+
opt = { ...opt, saveMethod: 'insert' };
|
|
507
507
|
}
|
|
508
508
|
const op = `saveAsDBM(${dbm.id})`;
|
|
509
509
|
const started = this.logSaveStarted(op, dbm, table);
|
|
@@ -521,8 +521,8 @@ class CommonDao {
|
|
|
521
521
|
const dbms = await this.bmsToDBM(bms, opt);
|
|
522
522
|
if (opt.ensureUniqueId)
|
|
523
523
|
throw new js_lib_1.AppError('ensureUniqueId is not supported in saveBatch');
|
|
524
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
525
|
-
opt
|
|
524
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
525
|
+
opt = { ...opt, saveMethod: 'insert' };
|
|
526
526
|
}
|
|
527
527
|
const op = `saveBatch ${dbms.length} row(s) (${(0, js_lib_1._truncate)(dbms
|
|
528
528
|
.slice(0, 10)
|
|
@@ -545,8 +545,8 @@ class CommonDao {
|
|
|
545
545
|
if (opt.ensureUniqueId)
|
|
546
546
|
throw new js_lib_1.AppError('ensureUniqueId is not supported in saveBatch');
|
|
547
547
|
}
|
|
548
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
549
|
-
opt
|
|
548
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
549
|
+
opt = { ...opt, saveMethod: 'insert' };
|
|
550
550
|
}
|
|
551
551
|
const op = `saveBatchAsDBM ${dbms.length} row(s) (${(0, js_lib_1._truncate)(dbms
|
|
552
552
|
.slice(0, 10)
|
package/package.json
CHANGED
|
@@ -553,7 +553,7 @@ export class CommonDao<
|
|
|
553
553
|
opt: CommonDaoStreamForEachOptions<ID> = {},
|
|
554
554
|
): Promise<void> {
|
|
555
555
|
q.table = opt.table || q.table
|
|
556
|
-
opt.errorMode
|
|
556
|
+
opt.errorMode ||= ErrorMode.SUPPRESS
|
|
557
557
|
|
|
558
558
|
const op = `streamQueryIdsForEach(${q.pretty()})`
|
|
559
559
|
const started = this.logStarted(op, q.table, true)
|
|
@@ -614,8 +614,8 @@ export class CommonDao<
|
|
|
614
614
|
const dbm = await this.bmToDBM(bm as BM, opt)
|
|
615
615
|
const table = opt.table || this.cfg.table
|
|
616
616
|
if (opt.ensureUniqueId && idWasGenerated) await this.ensureUniqueId(table, dbm)
|
|
617
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
618
|
-
opt
|
|
617
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
618
|
+
opt = { ...opt, saveMethod: 'insert' }
|
|
619
619
|
}
|
|
620
620
|
const op = `save(${dbm.id})`
|
|
621
621
|
const started = this.logSaveStarted(op, bm, table)
|
|
@@ -672,8 +672,8 @@ export class CommonDao<
|
|
|
672
672
|
dbm = this.anyToDBM(dbm, opt)
|
|
673
673
|
if (opt.ensureUniqueId && idWasGenerated) await this.ensureUniqueId(table, dbm)
|
|
674
674
|
}
|
|
675
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
676
|
-
opt
|
|
675
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
676
|
+
opt = { ...opt, saveMethod: 'insert' }
|
|
677
677
|
}
|
|
678
678
|
const op = `saveAsDBM(${dbm.id})`
|
|
679
679
|
const started = this.logSaveStarted(op, dbm, table)
|
|
@@ -691,8 +691,8 @@ export class CommonDao<
|
|
|
691
691
|
bms.forEach(bm => this.assignIdCreatedUpdated(bm, opt))
|
|
692
692
|
const dbms = await this.bmsToDBM(bms as BM[], opt)
|
|
693
693
|
if (opt.ensureUniqueId) throw new AppError('ensureUniqueId is not supported in saveBatch')
|
|
694
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
695
|
-
opt
|
|
694
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
695
|
+
opt = { ...opt, saveMethod: 'insert' }
|
|
696
696
|
}
|
|
697
697
|
|
|
698
698
|
const op = `saveBatch ${dbms.length} row(s) (${_truncate(
|
|
@@ -722,8 +722,8 @@ export class CommonDao<
|
|
|
722
722
|
dbms = this.anyToDBMs(dbms, opt)
|
|
723
723
|
if (opt.ensureUniqueId) throw new AppError('ensureUniqueId is not supported in saveBatch')
|
|
724
724
|
}
|
|
725
|
-
if (this.cfg.immutable && !opt.allowMutability) {
|
|
726
|
-
opt
|
|
725
|
+
if (this.cfg.immutable && !opt.allowMutability && !opt.saveMethod) {
|
|
726
|
+
opt = { ...opt, saveMethod: 'insert' }
|
|
727
727
|
}
|
|
728
728
|
const op = `saveBatchAsDBM ${dbms.length} row(s) (${_truncate(
|
|
729
729
|
dbms
|