@naturalcycles/db-lib 8.34.0 → 8.34.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.
|
@@ -571,7 +571,7 @@ class CommonDao {
|
|
|
571
571
|
if (!id)
|
|
572
572
|
return 0;
|
|
573
573
|
this.requireWriteAccess();
|
|
574
|
-
if (!opt.
|
|
574
|
+
if (!opt.allowMutability)
|
|
575
575
|
this.requireObjectMutability();
|
|
576
576
|
const op = `deleteById(${id})`;
|
|
577
577
|
const table = opt.table || this.cfg.table;
|
|
@@ -582,7 +582,7 @@ class CommonDao {
|
|
|
582
582
|
}
|
|
583
583
|
async deleteByIds(ids, opt = {}) {
|
|
584
584
|
this.requireWriteAccess();
|
|
585
|
-
if (!opt.
|
|
585
|
+
if (!opt.allowMutability)
|
|
586
586
|
this.requireObjectMutability();
|
|
587
587
|
const op = `deleteByIds(${ids.join(', ')})`;
|
|
588
588
|
const table = opt.table || this.cfg.table;
|
|
@@ -598,7 +598,7 @@ class CommonDao {
|
|
|
598
598
|
*/
|
|
599
599
|
async deleteByQuery(q, opt = {}) {
|
|
600
600
|
this.requireWriteAccess();
|
|
601
|
-
if (!opt.
|
|
601
|
+
if (!opt.allowMutability)
|
|
602
602
|
this.requireObjectMutability();
|
|
603
603
|
q.table = opt.table || q.table;
|
|
604
604
|
const op = `deleteByQuery(${q.pretty()})`;
|
|
@@ -140,7 +140,7 @@ export interface CommonDaoOptions extends CommonDBOptions {
|
|
|
140
140
|
/**
|
|
141
141
|
* @default false (for streams). Setting to true enables deletion of immutable objects
|
|
142
142
|
*/
|
|
143
|
-
|
|
143
|
+
allowMutability?: boolean;
|
|
144
144
|
/**
|
|
145
145
|
* If true - data will be anonymized (by calling a BaseDao.anonymize() hook that you can extend in your Dao implementation).
|
|
146
146
|
* Only applicable to loading/querying/streaming_loading operations (n/a for saving).
|
package/package.json
CHANGED
|
@@ -174,7 +174,7 @@ export interface CommonDaoOptions extends CommonDBOptions {
|
|
|
174
174
|
/**
|
|
175
175
|
* @default false (for streams). Setting to true enables deletion of immutable objects
|
|
176
176
|
*/
|
|
177
|
-
|
|
177
|
+
allowMutability?: boolean
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
* If true - data will be anonymized (by calling a BaseDao.anonymize() hook that you can extend in your Dao implementation).
|
|
@@ -771,7 +771,7 @@ export class CommonDao<
|
|
|
771
771
|
async deleteById(id?: string, opt: CommonDaoOptions = {}): Promise<number> {
|
|
772
772
|
if (!id) return 0
|
|
773
773
|
this.requireWriteAccess()
|
|
774
|
-
if (!opt.
|
|
774
|
+
if (!opt.allowMutability) this.requireObjectMutability()
|
|
775
775
|
const op = `deleteById(${id})`
|
|
776
776
|
const table = opt.table || this.cfg.table
|
|
777
777
|
const started = this.logStarted(op, table)
|
|
@@ -782,7 +782,7 @@ export class CommonDao<
|
|
|
782
782
|
|
|
783
783
|
async deleteByIds(ids: string[], opt: CommonDaoOptions = {}): Promise<number> {
|
|
784
784
|
this.requireWriteAccess()
|
|
785
|
-
if (!opt.
|
|
785
|
+
if (!opt.allowMutability) this.requireObjectMutability()
|
|
786
786
|
const op = `deleteByIds(${ids.join(', ')})`
|
|
787
787
|
const table = opt.table || this.cfg.table
|
|
788
788
|
const started = this.logStarted(op, table)
|
|
@@ -801,7 +801,7 @@ export class CommonDao<
|
|
|
801
801
|
opt: CommonDaoStreamForEachOptions<DBM> & { stream?: boolean } = {},
|
|
802
802
|
): Promise<number> {
|
|
803
803
|
this.requireWriteAccess()
|
|
804
|
-
if (!opt.
|
|
804
|
+
if (!opt.allowMutability) this.requireObjectMutability()
|
|
805
805
|
q.table = opt.table || q.table
|
|
806
806
|
const op = `deleteByQuery(${q.pretty()})`
|
|
807
807
|
const started = this.logStarted(op, q.table)
|