@samet-it/be-db-common 1.1.5 → 1.1.7

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.
@@ -15,28 +15,31 @@ const be_base_common_1 = require("@samet-it/be-base-common");
15
15
  const query_1 = require("@leyyo/query");
16
16
  const type_1 = require("@leyyo/type");
17
17
  const error_1 = require("../error");
18
+ const FORBIDDEN_KEYS = ['id', 'urn', '_trashId', 'createdAt', 'createdBy', 'updatedAt', 'updatedBy', "_rev", '_search', '_alpha', '_irregular'];
19
+ const STRICT_KEYS = ['id', 'urn', '_trashId', "_rev", '_irregular'];
18
20
  // noinspection JSUnusedGlobalSymbols
19
21
  /**
20
22
  * DB repository abstract class
21
23
  *
22
24
  * Generics:
23
- * - 0-`CONN`: db connection {@link DbConnectionBase}
25
+ * - 0-`CONN`: db connection {@link DbConnectionLike}
24
26
  * - 1-`OPT`: db execution options {@link DbExecOpt}
25
- * - 2-`ENT`: entity {@link Entity}
26
- * - 3-`ID`: id type {@link KeyValue}
27
- * - 4-`URN`: urn interface {@link UrnDocLike}
28
- * - 5-`VIEW`: view interface for presentation layer {@link View}
29
- * - 6-`PAIR`: pair interface for presentation layer {@link Pair}
30
- * - 7-`PORTION`: portion interface for presentation layer {@link Portion}
31
- * - 8-`KEYS`: keys to autocomplete, def: keys of {@link Entity}
32
- * - 9-`DIMS`: dimensions for presentation layer {@link DefDims}
27
+ * - 2-`META`: query result metadata {@link DbMeta}
28
+ * - 3-`ENT`: entity {@link Entity}
29
+ * - 4-`ID`: id type {@link KeyValue}
30
+ * - 5-`URN`: urn interface {@link UrnDocLike}
31
+ * - 6-`VIEW`: view interface for presentation layer {@link View}
32
+ * - 7-`PAIR`: pair interface for presentation layer {@link Pair}
33
+ * - 8-`PORTION`: portion interface for presentation layer {@link Portion}
34
+ * - 9-`KEYS`: keys to autocomplete, def: keys of {@link Entity}
35
+ * - 10-`DIMS`: dimensions for presentation layer {@link DefDims}
33
36
  * */
34
37
  class DbRepo {
35
38
  // endregion protected-property
36
39
  /**
37
40
  * Constructor
38
41
  *
39
- * @param {DbConnectionBase} conn - db connection
42
+ * @param {DbConnectionLike} conn - db connection
40
43
  * @param {DbRepoOpt} opt - options
41
44
  * */
42
45
  constructor(conn, opt) {
@@ -86,41 +89,22 @@ class DbRepo {
86
89
  if (!this._opt.urnPrefix) {
87
90
  throw new error_1.DbInvalidValueError('Urn prefix', { where: 'DbRepo', method: 'constructor', type: typeof this._opt.urnPrefix });
88
91
  }
89
- this._opt.forbiddenSet = this._checkForbiddenList(this._opt.forbiddenSet, ['id', '_urn', '_trashId', 'createdAt', 'createdBy']);
90
- this._opt.forbiddenUnset = this._checkForbiddenList(this._opt.forbiddenUnset, ['id', '_urn', '_trashId', 'createdAt', 'createdBy', 'updatedAt', 'updatedBy']);
91
- this._props = Object.assign({ conn }, this._opt);
92
- delete this._opt;
93
- }
94
- // region protected-method
95
- _removeFieldForForbidden(fields, flag, field) {
96
- if (this._opt[flag] !== true) {
97
- const index = fields.indexOf(field);
98
- if (index >= 0) {
99
- fields.splice(index, 0);
100
- }
101
- }
102
- }
103
- _checkForbiddenList(given, def) {
104
- if (!Array.isArray(given)) {
105
- given = [];
92
+ if (!Array.isArray(this._opt.forbiddenSet)) {
93
+ this._opt.forbiddenSet = [...FORBIDDEN_KEYS];
106
94
  }
107
95
  else {
108
- given = given.filter(v => (0, type_1.isText)(v));
109
- }
110
- if (given.length < 1) {
111
- given.push(...def);
96
+ STRICT_KEYS.forEach(k => {
97
+ if (!this._opt.forbiddenSet.includes(k)) {
98
+ this._opt.forbiddenSet.push(k);
99
+ }
100
+ });
112
101
  }
113
- this._removeFieldForForbidden(given, 'useCreatedAt', 'createdAt');
114
- this._removeFieldForForbidden(given, 'useCreatedBy', 'createdBy');
115
- this._removeFieldForForbidden(given, 'useUpdatedAt', 'updatedAt');
116
- this._removeFieldForForbidden(given, 'useUpdatedBy', 'updatedBy');
117
- this._removeFieldForForbidden(given, 'useRevision', '_rev');
118
- this._removeFieldForForbidden(given, 'useVersion', '_ver');
119
- return given;
102
+ this._props = Object.assign({ conn }, this._opt);
103
+ delete this._opt;
120
104
  }
105
+ // region protected-method
121
106
  get _now() {
122
- const { useIsoDate } = this._props;
123
- return useIsoDate ? new Date().toISOString() : Date.now();
107
+ return this.hasIsoDate ? new Date().toISOString() : Date.now();
124
108
  }
125
109
  get _randomIndexName() {
126
110
  return 'idx_' + (0, node_crypto_1.randomUUID)().match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
@@ -151,27 +135,25 @@ class DbRepo {
151
135
  return name;
152
136
  }
153
137
  /**
154
- * Fetch urn from doc as doc._urn
138
+ * Fetch urn from doc as doc.urn
155
139
  * */
156
140
  _urnFromDoc(doc, method) {
157
- const { path } = this._props;
158
- const param = { where: 'DbRepo', path, method };
141
+ const param = { where: 'DbRepo', path: this.path, method };
159
142
  (0, type_1.assertObject)(doc, Object.assign({ field: 'doc' }, param));
160
- (0, type_1.assertText)(doc._urn, Object.assign({ field: 'urn' }, param));
161
- return doc._urn;
143
+ (0, type_1.assertText)(doc.urn, Object.assign({ field: 'urn' }, param));
144
+ return doc.urn;
162
145
  }
163
146
  _checkKey(value) {
164
- const { useNumericId } = this._props;
165
147
  let id;
166
148
  switch (typeof value) {
167
149
  case "string":
168
150
  const str = value.trim();
169
151
  if (str) {
170
152
  if (this._isUrn(str)) {
171
- return [str, '_urn'];
153
+ return [str, 'urn'];
172
154
  }
173
155
  else {
174
- if (useNumericId) {
156
+ if (this.hasNumericId) {
175
157
  try {
176
158
  id = parseInt(str);
177
159
  }
@@ -189,7 +171,7 @@ class DbRepo {
189
171
  }
190
172
  break;
191
173
  case "number":
192
- if (useNumericId) {
174
+ if (this.hasNumericId) {
193
175
  return [value, 'id'];
194
176
  }
195
177
  else {
@@ -206,9 +188,6 @@ class DbRepo {
206
188
  if (obj.urn !== undefined) {
207
189
  return this._checkKey(obj.urn);
208
190
  }
209
- if (obj._urn !== undefined) {
210
- return this._checkKey(obj._urn);
211
- }
212
191
  break;
213
192
  }
214
193
  return [undefined, undefined];
@@ -224,7 +203,7 @@ class DbRepo {
224
203
  for (const item of keys) {
225
204
  const [key, field] = this._checkKey(item);
226
205
  if (field) {
227
- if ((field === '_urn') && !result.urns.includes(key)) {
206
+ if ((field === 'urn') && !result.urns.includes(key)) {
228
207
  result.urns.push(key);
229
208
  result.ordered.push([key, field]);
230
209
  }
@@ -237,12 +216,10 @@ class DbRepo {
237
216
  return result;
238
217
  }
239
218
  _isUrn(key) {
240
- const { urnPrefix } = this._props;
241
- return (typeof key === 'string') && key.startsWith(urnPrefix + ':');
219
+ return (typeof key === 'string') && key.startsWith(this.urnPrefix + ':');
242
220
  }
243
221
  _keyToUrn(key) {
244
- const { urnPrefix } = this._props;
245
- return `${urnPrefix}:${key}`;
222
+ return `${this.urnPrefix}:${key}`;
246
223
  }
247
224
  // endregion protected-method
248
225
  // region getter
@@ -254,12 +231,210 @@ class DbRepo {
254
231
  $cast() {
255
232
  return this;
256
233
  }
234
+ /** @inheritDoc */
235
+ get isEnabled() {
236
+ return this._props.conn.isEnabled;
237
+ }
238
+ /** @inheritDoc */
239
+ get userFetcher() {
240
+ return this._props.conn.props.userFetcher;
241
+ }
242
+ /** @inheritDoc */
243
+ get conn() {
244
+ return this._props.conn;
245
+ }
246
+ /** @inheritDoc */
247
+ get isConnected() {
248
+ return this._props.conn.isConnected;
249
+ }
250
+ /** @inheritDoc */
251
+ get cache() {
252
+ return this._props.cache;
253
+ }
254
+ /** @inheritDoc */
255
+ get modelVersion() {
256
+ return this._props.version;
257
+ }
258
+ /** @inheritDoc */
259
+ get urnDelimiter() {
260
+ return this._props.urnDelimiter;
261
+ }
262
+ /** @inheritDoc */
263
+ get urnPrefix() {
264
+ return this._props.urnPrefix;
265
+ }
266
+ /** @inheritDoc */
267
+ get hasNumericId() {
268
+ return this._props.useNumericId;
269
+ }
270
+ /** @inheritDoc */
271
+ get hasIsoDate() {
272
+ return this._props.useIsoDate;
273
+ }
274
+ /** @inheritDoc */
275
+ get isIdSame() {
276
+ return this._props.idSame;
277
+ }
278
+ /** @inheritDoc */
279
+ get hasSoftDelete() {
280
+ return this._props.useSoftDelete;
281
+ }
282
+ /** @inheritDoc */
283
+ get hasCreatedAt() {
284
+ return this._props.useCreatedAt;
285
+ }
286
+ /** @inheritDoc */
287
+ get hasCreatedBy() {
288
+ return this._props.useCreatedBy;
289
+ }
290
+ /** @inheritDoc */
291
+ get hasUpdatedAt() {
292
+ return this._props.useUpdatedAt;
293
+ }
294
+ /** @inheritDoc */
295
+ get hasUpdatedBy() {
296
+ return this._props.useUpdatedBy;
297
+ }
298
+ /** @inheritDoc */
299
+ get hasVersion() {
300
+ return this._props.useVersion;
301
+ }
302
+ /** @inheritDoc */
303
+ get hasRevision() {
304
+ return this._props.useRevision;
305
+ }
306
+ /** @inheritDoc */
307
+ get isNoInsert() {
308
+ return this._props.noInsert;
309
+ }
310
+ /** @inheritDoc */
311
+ get isNoUpdate() {
312
+ return this._props.noUpdate;
313
+ }
314
+ /** @inheritDoc */
315
+ get isNoTrash() {
316
+ return this._props.noTrash;
317
+ }
318
+ /** @inheritDoc */
319
+ get isNoRemove() {
320
+ return this._props.noRemove;
321
+ }
322
+ /** @inheritDoc */
323
+ get alphaFn() {
324
+ return this._props.alphaFn;
325
+ }
326
+ /** @inheritDoc */
327
+ get searchFn() {
328
+ return this._props.searchFn;
329
+ }
330
+ /** @inheritDoc */
331
+ get irregularFn() {
332
+ return this._props.irregularFn;
333
+ }
334
+ /** @inheritDoc */
335
+ get forbiddenSet() {
336
+ return [...this._props.forbiddenSet];
337
+ }
338
+ /** @inheritDoc */
339
+ get path() {
340
+ return this._props.path;
341
+ }
342
+ /** @inheritDoc */
343
+ get table() {
344
+ return this._props.table;
345
+ }
346
+ /** @inheritDoc */
347
+ get urnLength() {
348
+ return this._props.urnLength;
349
+ }
257
350
  // endregion getter
351
+ // region field-value
352
+ /** {@inheritDoc} */
353
+ checkError(err, opt) {
354
+ var _a, _b, _c;
355
+ const size = be_base_common_1.errorHandler.addStat(err);
356
+ const ignoredErrors = (_a = opt === null || opt === void 0 ? void 0 : opt.ignoredErrors) !== null && _a !== void 0 ? _a : [];
357
+ if (ignoredErrors.includes(err) || ignoredErrors.includes(err.name)) {
358
+ return;
359
+ }
360
+ if (opt === null || opt === void 0 ? void 0 : opt.silent) {
361
+ if (size < 100) {
362
+ this.logger.warn(be_base_common_1.errorHandler.common.logText(err, ((_b = opt.name) !== null && _b !== void 0 ? _b : 'Database error'), size));
363
+ }
364
+ return;
365
+ }
366
+ if (size < 100) {
367
+ this.logger.error(be_base_common_1.errorHandler.common.logText(err, ((_c = opt.name) !== null && _c !== void 0 ? _c : 'Database error'), size));
368
+ }
369
+ if (err instanceof error_1.DbError) {
370
+ throw err;
371
+ }
372
+ else {
373
+ throw be_base_common_1.errorHandler.common.castForClass(error_1.DbError, err, { queryName: opt.name });
374
+ }
375
+ }
376
+ /** {@inheritDoc} */
377
+ f(field) {
378
+ return this.field(field);
379
+ }
380
+ v(value) {
381
+ return this.value(value);
382
+ }
383
+ /** {@inheritDoc} */
384
+ rows(rows) {
385
+ if (rows && Array.isArray(rows) && (rows.length > 0)) {
386
+ return rows.filter(row => row['_trashId'] === undefined);
387
+ }
388
+ return [];
389
+ }
390
+ /** {@inheritDoc} */
391
+ row(row) {
392
+ if (row && row['_trashId'] === undefined) {
393
+ return row;
394
+ }
395
+ return undefined;
396
+ }
397
+ /** {@inheritDoc} */
398
+ first(rows) {
399
+ if (rows && Array.isArray(rows) && (rows.length > 0)) {
400
+ return rows[0];
401
+ }
402
+ return undefined;
403
+ }
404
+ // endregion field-value
405
+ // region option
406
+ /** {@inheritDoc} */
407
+ buildOpt(p1, name) {
408
+ const opt = (typeof p1 === 'string' ? { name: p1 } : Object.assign({}, p1));
409
+ if (typeof opt.name === undefined && typeof name !== undefined) {
410
+ opt.name = name;
411
+ }
412
+ opt.name = opt.name ? `[${opt.name}]` : '';
413
+ return opt;
414
+ }
415
+ // endregion option
416
+ // region query
417
+ /** {@inheritDoc} */
418
+ exec(fn, p1) {
419
+ return __awaiter(this, void 0, void 0, function* () {
420
+ if (!this.isEnabled) {
421
+ return undefined;
422
+ }
423
+ const opt = this.buildOpt(p1);
424
+ try {
425
+ return yield fn;
426
+ }
427
+ catch (err) {
428
+ this.checkError(err, opt);
429
+ return undefined;
430
+ }
431
+ });
432
+ }
433
+ // endregion query
258
434
  // region urn
259
435
  /** @inheritDoc */
260
436
  toUrn(urnRec) {
261
- const { urnPrefix, urnDelimiter } = this._props;
262
- return `${urnPrefix}:${this.$toUrnTuple(urnRec).join(urnDelimiter)}`;
437
+ return `${this.urnPrefix}:${this.$toUrnTuple(urnRec).join(this.urnDelimiter)}`;
263
438
  }
264
439
  /** @inheritDoc */
265
440
  $toUrnTuple(urnRec) {
@@ -270,11 +445,10 @@ class DbRepo {
270
445
  /** @inheritDoc */
271
446
  get(k1, p1) {
272
447
  return __awaiter(this, void 0, void 0, function* () {
273
- const { conn } = this._props;
274
- const opt = conn.buildOpt(p1, 'get');
448
+ const opt = this.buildOpt(p1, 'get');
275
449
  const [key, field] = this._checkKey(k1);
276
450
  switch (field) {
277
- case "_urn":
451
+ case "urn":
278
452
  return this.getByPrimary(key, opt, true);
279
453
  case "id":
280
454
  return this.getBySecondary(key, opt, true);
@@ -286,15 +460,14 @@ class DbRepo {
286
460
  /** @inheritDoc */
287
461
  getByPrimary(key, p1, ignoreCheck) {
288
462
  return __awaiter(this, void 0, void 0, function* () {
289
- const { cache, conn } = this._props;
290
- const opt = conn.buildOpt(p1, 'getByPrimary');
463
+ const opt = this.buildOpt(p1, 'getByPrimary');
291
464
  if (!ignoreCheck) {
292
465
  (0, type_1.assertText)(key, { field: 'key', where: 'DbRepo', method: 'getByPrimary', queryName: opt.name });
293
466
  }
294
467
  let found;
295
- if (!opt.noCache && cache.props.isConnected) {
468
+ if (!opt.noCache && this.cache.isConnected) {
296
469
  try {
297
- found = yield cache.getByPrimary(key, opt);
470
+ found = yield this.cache.getByPrimary(key, opt);
298
471
  }
299
472
  catch (e) {
300
473
  this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'getByPrimary', 'cache', 'getByPrimary'));
@@ -304,8 +477,8 @@ class DbRepo {
304
477
  }
305
478
  }
306
479
  found = yield this.$getByPrimary(key, opt, true);
307
- if (!opt.noCache && found && cache.props.isConnected) {
308
- cache.ingestDoc(found, opt)
480
+ if (!opt.noCache && found && this.cache.isConnected) {
481
+ this.cache.ingestDoc(found, opt)
309
482
  .then()
310
483
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'getByPrimary', 'cache', 'ingestDoc')));
311
484
  }
@@ -315,23 +488,22 @@ class DbRepo {
315
488
  /** @inheritDoc */
316
489
  getBySecondary(key, p1, ignoreCheck) {
317
490
  return __awaiter(this, void 0, void 0, function* () {
318
- const { cache, useNumericId, idSame, conn } = this._props;
319
- const opt = conn.buildOpt(p1, 'getBySecondary');
491
+ const opt = this.buildOpt(p1, 'getBySecondary');
320
492
  if (!ignoreCheck) {
321
- if (useNumericId) {
493
+ if (this.hasNumericId) {
322
494
  (0, type_1.assertInteger)(key, { field: 'key', where: 'DbRepo', method: 'getBySecondary', queryName: opt.name });
323
495
  }
324
496
  else {
325
497
  (0, type_1.assertText)(key, { field: 'key', where: 'DbRepo', method: 'getBySecondary', queryName: opt.name });
326
498
  }
327
499
  }
328
- if (idSame) {
500
+ if (this.isIdSame) {
329
501
  return this.getByPrimary(this._keyToUrn(key), opt, true);
330
502
  }
331
503
  let found;
332
- if (!opt.noCache && cache.props.isConnected) {
504
+ if (!opt.noCache && this.cache.isConnected) {
333
505
  try {
334
- found = yield cache.getBySecondary(key, opt);
506
+ found = yield this.cache.getBySecondary(key, opt);
335
507
  if (found) {
336
508
  return found;
337
509
  }
@@ -341,8 +513,8 @@ class DbRepo {
341
513
  }
342
514
  }
343
515
  found = yield this.$getBySecondary(key, opt, true);
344
- if (found && cache.props.isConnected) {
345
- cache.ingestDoc(found, opt)
516
+ if (found && this.cache.isConnected) {
517
+ this.cache.ingestDoc(found, opt)
346
518
  .then()
347
519
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'getBySecondary', 'cache', 'ingestDoc')));
348
520
  }
@@ -354,11 +526,10 @@ class DbRepo {
354
526
  /** @inheritDoc */
355
527
  exists(k1, p1) {
356
528
  return __awaiter(this, void 0, void 0, function* () {
357
- const { conn } = this._props;
358
- const opt = conn.buildOpt(p1, 'exists');
529
+ const opt = this.buildOpt(p1, 'exists');
359
530
  const [key, field] = this._checkKey(k1);
360
531
  switch (field) {
361
- case "_urn":
532
+ case "urn":
362
533
  return this.existsByPrimary(key, opt, true);
363
534
  case "id":
364
535
  return this.existsBySecondary(key, opt, true);
@@ -371,14 +542,13 @@ class DbRepo {
371
542
  /** @inheritDoc */
372
543
  existsByPrimary(key, p1, ignoreCheck) {
373
544
  return __awaiter(this, void 0, void 0, function* () {
374
- const { cache, conn } = this._props;
375
- const opt = conn.buildOpt(p1, 'existsByPrimary');
545
+ const opt = this.buildOpt(p1, 'existsByPrimary');
376
546
  if (!ignoreCheck) {
377
547
  (0, type_1.assertText)(key, { field: 'key', where: 'DbRepo', method: 'existsByPrimary', queryName: opt.name });
378
548
  }
379
- if (!opt.noCache && cache.props.isConnected) {
549
+ if (!opt.noCache && this.cache.isConnected) {
380
550
  try {
381
- const found = yield cache.getByPrimary(key, opt);
551
+ const found = yield this.cache.getByPrimary(key, opt);
382
552
  if (found) {
383
553
  return true;
384
554
  }
@@ -393,22 +563,21 @@ class DbRepo {
393
563
  /** @inheritDoc */
394
564
  existsBySecondary(key, p1, ignoreCheck) {
395
565
  return __awaiter(this, void 0, void 0, function* () {
396
- const { cache, useNumericId, idSame, conn } = this._props;
397
- const opt = conn.buildOpt(p1, 'existsBySecondary');
566
+ const opt = this.buildOpt(p1, 'existsBySecondary');
398
567
  if (!ignoreCheck) {
399
- if (useNumericId) {
568
+ if (this.hasNumericId) {
400
569
  (0, type_1.assertInteger)(key, { field: 'key', where: 'DbRepo', method: 'existsBySecondary', queryName: opt.name });
401
570
  }
402
571
  else {
403
572
  (0, type_1.assertText)(key, { field: 'key', where: 'DbRepo', method: 'existsBySecondary', queryName: opt.name });
404
573
  }
405
574
  }
406
- if (!idSame) {
575
+ if (!this.isIdSame) {
407
576
  return this.existsByPrimary(this._keyToUrn(key));
408
577
  }
409
- if (!opt.noCache && cache.props.isConnected) {
578
+ if (!opt.noCache && this.cache.isConnected) {
410
579
  try {
411
- const found = yield cache.getBySecondary(key, opt);
580
+ const found = yield this.cache.getBySecondary(key, opt);
412
581
  if (found) {
413
582
  return true;
414
583
  }
@@ -425,8 +594,7 @@ class DbRepo {
425
594
  /** @inheritDoc */
426
595
  list(keys, p1, ignoreCheck) {
427
596
  return __awaiter(this, void 0, void 0, function* () {
428
- const { conn, cache } = this._props;
429
- const opt = conn.buildOpt(p1, 'list');
597
+ const opt = this.buildOpt(p1, 'list');
430
598
  if (!ignoreCheck) {
431
599
  (0, type_1.assertArray)(keys, { field: 'keys', where: 'DbRepo', method: 'list', queryName: opt.name });
432
600
  }
@@ -437,15 +605,15 @@ class DbRepo {
437
605
  const docs = [];
438
606
  let founds = [];
439
607
  if (result.urns.length > 0) {
440
- if (!opt.noCache && cache.props.isConnected) {
608
+ if (!opt.noCache && this.cache.isConnected) {
441
609
  try {
442
- founds = yield cache.getByPrimaryMore(result.urns, opt);
610
+ founds = yield this.cache.getByPrimaryMore(result.urns, opt);
443
611
  }
444
612
  catch (e) {
445
613
  this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'list', 'cache', 'getByPrimary'));
446
614
  }
447
615
  founds.forEach(val => {
448
- const index = result.urns.indexOf(val._urn);
616
+ const index = result.urns.indexOf(val.urn);
449
617
  if (index >= 0) {
450
618
  result.urns.splice(index, 1);
451
619
  }
@@ -455,8 +623,8 @@ class DbRepo {
455
623
  if (result.urns.length > 0) {
456
624
  founds = yield this.$listByPrimary(result.urns, opt, true);
457
625
  if (founds.length > 0) {
458
- if (!opt.noCache && cache.props.isConnected) {
459
- founds.forEach(found => cache.ingestDoc(found, opt)
626
+ if (!opt.noCache && this.cache.isConnected) {
627
+ founds.forEach(found => this.cache.ingestDoc(found, opt)
460
628
  .then()
461
629
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'list', 'cache', 'ingestDoc'))));
462
630
  }
@@ -465,9 +633,9 @@ class DbRepo {
465
633
  }
466
634
  }
467
635
  if (result.ids.length > 0) {
468
- if (!opt.noCache && cache.props.isConnected) {
636
+ if (!opt.noCache && this.cache.isConnected) {
469
637
  try {
470
- founds = yield cache.getBySecondaryMore(result.ids, opt);
638
+ founds = yield this.cache.getBySecondaryMore(result.ids, opt);
471
639
  }
472
640
  catch (e) {
473
641
  this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'list', 'cache', 'getBySecondary'));
@@ -483,8 +651,8 @@ class DbRepo {
483
651
  if (result.ids.length > 0) {
484
652
  founds = yield this.$listBySecondary(result.ids, opt, true);
485
653
  if (founds.length > 0) {
486
- if (!opt.noCache && cache.props.isConnected) {
487
- founds.forEach(found => cache.ingestDoc(found, opt)
654
+ if (!opt.noCache && this.cache.isConnected) {
655
+ founds.forEach(found => this.cache.ingestDoc(found, opt)
488
656
  .then()
489
657
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'list', 'cache', 'ingestDoc'))));
490
658
  }
@@ -500,8 +668,7 @@ class DbRepo {
500
668
  /** @inheritDoc */
501
669
  filter(query, p1) {
502
670
  return __awaiter(this, void 0, void 0, function* () {
503
- const { conn } = this._props;
504
- const opt = conn.buildOpt(p1, 'filter');
671
+ const opt = this.buildOpt(p1, 'filter');
505
672
  return this.$filter(query_1.queryParser.exec(query, [], opt.name), opt);
506
673
  });
507
674
  }
@@ -510,36 +677,42 @@ class DbRepo {
510
677
  /** @inheritDoc */
511
678
  insert(doc, p1, ignoreCheck) {
512
679
  return __awaiter(this, void 0, void 0, function* () {
513
- const { useCreatedAt, conn, noInsert, useNumericId, useCreatedBy, useUpdatedAt, useUpdatedBy } = this._props;
514
- const opt = conn.buildOpt(p1, 'insert');
680
+ const opt = this.buildOpt(p1, 'insert');
515
681
  const param = { where: 'DbRepo', method: 'insert', queryName: opt.name };
516
- if (noInsert) {
682
+ if (this.isNoInsert) {
517
683
  throw new error_1.DbNotSupportedError('Insert', param);
518
684
  }
519
685
  if (!ignoreCheck) {
520
686
  (0, type_1.assertObject)(doc, Object.assign({ field: 'doc' }, param));
521
- if (useNumericId) {
687
+ if (this.hasNumericId) {
522
688
  (0, type_1.assertInteger)(doc.id, Object.assign({ field: 'doc.id' }, param));
523
689
  }
524
690
  else {
525
691
  (0, type_1.assertText)(doc.id, Object.assign({ field: 'doc.id' }, param));
526
692
  }
527
- (0, type_1.assertText)(doc._urn, Object.assign({ field: 'doc._urn' }, param));
693
+ (0, type_1.assertText)(doc.urn, Object.assign({ field: 'doc.urn' }, param));
528
694
  }
529
695
  if (!doc._trashId !== undefined) {
530
696
  delete doc._trashId;
531
697
  }
532
- if (useCreatedAt) {
698
+ if (this.hasCreatedAt) {
533
699
  doc.createdAt = this._now;
534
700
  }
535
- if (useCreatedBy) {
536
- // todo
701
+ let userId;
702
+ if (this.hasCreatedBy && this.userFetcher) {
703
+ doc.createdBy = (yield this.userFetcher());
704
+ userId = doc.createdBy;
537
705
  }
538
- if (useUpdatedAt) {
706
+ if (this.hasUpdatedAt) {
539
707
  doc.updatedAt = this._now;
540
708
  }
541
- if (useUpdatedBy) {
542
- // todo
709
+ if (this.hasUpdatedBy && this.userFetcher) {
710
+ if (userId) {
711
+ doc.createdBy = userId;
712
+ }
713
+ else {
714
+ doc.createdBy = (yield this.userFetcher());
715
+ }
543
716
  }
544
717
  return this.$insert(doc, opt);
545
718
  });
@@ -547,10 +720,9 @@ class DbRepo {
547
720
  /** @inheritDoc */
548
721
  inserts(docs, p1, ignoreCheck) {
549
722
  return __awaiter(this, void 0, void 0, function* () {
550
- const { noInsert, conn } = this._props;
551
- const opt = conn.buildOpt(p1, 'inserts');
723
+ const opt = this.buildOpt(p1, 'inserts');
552
724
  const param = { where: 'DbRepo', method: 'inserts', queryName: opt.name };
553
- if (noInsert) {
725
+ if (this.isNoInsert) {
554
726
  throw new error_1.DbNotSupportedError('Insert', param);
555
727
  }
556
728
  if (!ignoreCheck) {
@@ -568,12 +740,11 @@ class DbRepo {
568
740
  /** @inheritDoc */
569
741
  replace(doc, p1, ignoreCheck) {
570
742
  return __awaiter(this, void 0, void 0, function* () {
571
- const { cache, conn, useNumericId, useUpdatedAt, useUpdatedBy } = this._props;
572
- const opt = conn.buildOpt(p1, 'replace');
743
+ const opt = this.buildOpt(p1, 'replace');
573
744
  if (!ignoreCheck) {
574
745
  (0, type_1.assertObject)(doc, { field: 'doc', where: 'DbRepo', method: 'replace', queryName: opt.name });
575
- (0, type_1.assertText)(doc._urn, { field: 'doc._urn', where: 'DbRepo', method: 'replace', queryName: opt.name });
576
- if (useNumericId) {
746
+ (0, type_1.assertText)(doc.urn, { field: 'doc.urn', where: 'DbRepo', method: 'replace', queryName: opt.name });
747
+ if (this.hasNumericId) {
577
748
  (0, type_1.assertInteger)(doc.id, { field: 'doc.id', where: 'DbRepo', method: 'replace', queryName: opt.name });
578
749
  }
579
750
  else {
@@ -583,15 +754,15 @@ class DbRepo {
583
754
  if (doc._trashId !== undefined) {
584
755
  delete doc._trashId;
585
756
  }
586
- if (useUpdatedAt) {
757
+ if (this.hasUpdatedAt) {
587
758
  doc.updatedAt = this._now;
588
759
  }
589
- if (useUpdatedBy) {
590
- // todo
760
+ if (this.hasUpdatedBy && this.userFetcher) {
761
+ doc.createdBy = (yield this.userFetcher());
591
762
  }
592
763
  const replacedKey = yield this.$replace(doc, opt, true);
593
- if (!opt.noCache && cache.props.isConnected) {
594
- cache.clearDoc(replacedKey, opt)
764
+ if (!opt.noCache && this.cache.isConnected) {
765
+ this.cache.clearDoc(replacedKey, opt)
595
766
  .then()
596
767
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'replace', 'cache', 'clearDoc')));
597
768
  }
@@ -603,16 +774,15 @@ class DbRepo {
603
774
  /** @inheritDoc */
604
775
  upsert(doc, p1, ignoreCheck) {
605
776
  return __awaiter(this, void 0, void 0, function* () {
606
- const { noInsert, conn, noUpdate, cache, useNumericId, useUpdatedAt, useUpdatedBy } = this._props;
607
- const opt = conn.buildOpt(p1, 'upsert');
777
+ const opt = this.buildOpt(p1, 'upsert');
608
778
  const param = { where: 'DbRepo', method: 'upsert', queryName: opt.name };
609
- if (noInsert || noUpdate) {
779
+ if (this.isNoInsert || this.isNoUpdate) {
610
780
  throw new error_1.DbNotSupportedError('Upsert', param);
611
781
  }
612
782
  if (!ignoreCheck) {
613
783
  (0, type_1.assertObject)(doc, Object.assign({ field: 'doc' }, param));
614
- (0, type_1.assertText)(doc._urn, Object.assign({ field: 'doc._urn' }, param));
615
- if (useNumericId) {
784
+ (0, type_1.assertText)(doc.urn, Object.assign({ field: 'doc.urn' }, param));
785
+ if (this.hasNumericId) {
616
786
  (0, type_1.assertInteger)(doc.id, Object.assign({ field: 'doc.id' }, param));
617
787
  }
618
788
  else {
@@ -622,15 +792,15 @@ class DbRepo {
622
792
  if (doc._trashId !== undefined) {
623
793
  delete doc._trashId;
624
794
  }
625
- if (useUpdatedAt) {
795
+ if (this.hasUpdatedAt) {
626
796
  doc.updatedAt = this._now;
627
797
  }
628
- if (useUpdatedBy) {
629
- // todo
798
+ if (this.hasUpdatedBy && this.userFetcher) {
799
+ doc.createdBy = (yield this.userFetcher());
630
800
  }
631
801
  const createdKey = yield this.$replace(doc, opt, true);
632
- if (!opt.noCache && cache.props.isConnected) {
633
- cache.clearDoc(createdKey, opt)
802
+ if (!opt.noCache && this.cache.isConnected) {
803
+ this.cache.clearDoc(createdKey, opt)
634
804
  .then()
635
805
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'upsert', 'cache', 'clearDoc')));
636
806
  }
@@ -642,14 +812,13 @@ class DbRepo {
642
812
  /** @inheritDoc */
643
813
  update(k1, doc, p1, ignoreCheck) {
644
814
  return __awaiter(this, void 0, void 0, function* () {
645
- const { conn } = this._props;
646
- const opt = conn.buildOpt(p1, 'update');
815
+ const opt = this.buildOpt(p1, 'update');
647
816
  if (!ignoreCheck) {
648
817
  (0, type_1.assertObject)(doc, { field: 'doc', where: 'DbRepo', method: 'update', queryName: opt.name });
649
818
  }
650
819
  const [key, field] = this._checkKey(k1);
651
820
  switch (field) {
652
- case "_urn":
821
+ case "urn":
653
822
  return this.updateByPrimary(key, doc, opt, true);
654
823
  case "id":
655
824
  return this.updateBySecondary(key, doc, opt, true);
@@ -661,10 +830,9 @@ class DbRepo {
661
830
  /** @inheritDoc */
662
831
  updateByPrimary(key, doc, p1, ignoreCheck) {
663
832
  return __awaiter(this, void 0, void 0, function* () {
664
- const { noUpdate, conn, forbiddenSet, cache, useUpdatedAt, useUpdatedBy } = this._props;
665
- const opt = conn.buildOpt(p1, 'updateByPrimary');
833
+ const opt = this.buildOpt(p1, 'updateByPrimary');
666
834
  const param = { where: 'DbRepo', method: 'updateByPrimary', queryName: opt.name };
667
- if (noUpdate) {
835
+ if (this.isNoUpdate) {
668
836
  throw new error_1.DbNotSupportedError('Update', param);
669
837
  }
670
838
  if (!ignoreCheck) {
@@ -674,20 +842,20 @@ class DbRepo {
674
842
  if (doc._trashId !== undefined) {
675
843
  delete doc._trashId;
676
844
  }
677
- forbiddenSet.forEach(f => {
845
+ this._props.forbiddenSet.forEach(f => {
678
846
  if (doc[f] !== undefined) {
679
847
  delete doc[f];
680
848
  }
681
849
  });
682
- if (useUpdatedAt) {
850
+ if (this.hasUpdatedAt) {
683
851
  doc.updatedAt = this._now;
684
852
  }
685
- if (useUpdatedBy) {
686
- // todo
853
+ if (this.hasUpdatedBy && this.userFetcher) {
854
+ doc.createdBy = (yield this.userFetcher());
687
855
  }
688
856
  const updatedKey = yield this.$updateByPrimary(key, doc, opt, true);
689
- if (updatedKey && !opt.noCache && cache.props.isConnected) {
690
- cache.clearDoc(updatedKey, opt)
857
+ if (updatedKey && !opt.noCache && this.cache.isConnected) {
858
+ this.cache.clearDoc(updatedKey, opt)
691
859
  .then()
692
860
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'updateByPrimary', 'cache', 'clearDoc')));
693
861
  }
@@ -697,14 +865,13 @@ class DbRepo {
697
865
  /** @inheritDoc */
698
866
  updateBySecondary(key, doc, p1, ignoreCheck) {
699
867
  return __awaiter(this, void 0, void 0, function* () {
700
- const { forbiddenSet, noUpdate, cache, useNumericId, idSame, useUpdatedAt, useUpdatedBy, conn } = this._props;
701
- const opt = conn.buildOpt(p1, 'updateBySecondary');
868
+ const opt = this.buildOpt(p1, 'updateBySecondary');
702
869
  const param = { where: 'DbRepo', method: 'updateBySecondary', queryName: opt.name };
703
- if (noUpdate) {
870
+ if (this.isNoUpdate) {
704
871
  throw new error_1.DbNotSupportedError('Update', param);
705
872
  }
706
873
  if (!ignoreCheck) {
707
- if (useNumericId) {
874
+ if (this.hasNumericId) {
708
875
  (0, type_1.assertInteger)(key, Object.assign({ field: 'key' }, param));
709
876
  }
710
877
  else {
@@ -712,26 +879,26 @@ class DbRepo {
712
879
  }
713
880
  (0, type_1.assertObject)(doc, Object.assign({ field: 'doc' }, param));
714
881
  }
715
- if (idSame) {
882
+ if (this.isIdSame) {
716
883
  return this.updateBySecondary(this._keyToUrn(key), doc, opt, true);
717
884
  }
718
885
  if (doc._trashId !== undefined) {
719
886
  delete doc._trashId;
720
887
  }
721
- forbiddenSet.forEach(f => {
888
+ this._props.forbiddenSet.forEach(f => {
722
889
  if (doc[f] !== undefined) {
723
890
  delete doc[f];
724
891
  }
725
892
  });
726
- if (useUpdatedAt) {
893
+ if (this.hasUpdatedAt) {
727
894
  doc.updatedAt = this._now;
728
895
  }
729
- if (useUpdatedBy) {
730
- // todo
896
+ if (this.hasUpdatedBy && this.userFetcher) {
897
+ doc.createdBy = (yield this.userFetcher());
731
898
  }
732
899
  const updatedKey = yield this.$updateBySecondary(key, doc, opt, true);
733
- if (updatedKey && !opt.noCache && cache.props.isConnected) {
734
- cache.clearDoc(updatedKey, opt)
900
+ if (updatedKey && !opt.noCache && this.cache.isConnected) {
901
+ this.cache.clearDoc(updatedKey, opt)
735
902
  .then()
736
903
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'updateBySecondary', 'cache', 'clearDoc')));
737
904
  }
@@ -743,8 +910,7 @@ class DbRepo {
743
910
  /** @inheritDoc */
744
911
  set(key, doc, p1, ignoreCheck) {
745
912
  return __awaiter(this, void 0, void 0, function* () {
746
- const { conn } = this._props;
747
- const opt = conn.buildOpt(p1, 'set');
913
+ const opt = this.buildOpt(p1, 'set');
748
914
  if (!ignoreCheck) {
749
915
  (0, type_1.assertObject)(doc, { field: 'doc', where: 'DbRepo', method: 'set', queryName: opt.name });
750
916
  }
@@ -759,18 +925,16 @@ class DbRepo {
759
925
  /** @inheritDoc */
760
926
  unset(key, fields, p1, ignoreCheck) {
761
927
  return __awaiter(this, void 0, void 0, function* () {
762
- const { conn } = this._props;
763
- const opt = conn.buildOpt(p1, 'unset');
928
+ const opt = this.buildOpt(p1, 'unset');
764
929
  if (!ignoreCheck) {
765
930
  (0, type_1.assertArray)(fields, { field: 'fields', where: 'DbRepo', method: 'unset', queryName: opt.name });
766
931
  fields.forEach((field, index) => {
767
932
  (0, type_1.assertText)(field, { field: field, where: 'DbRepo', method: 'unset', index, queryName: opt.name });
768
933
  });
769
934
  }
770
- const { forbiddenUnset } = this._props;
771
935
  const doc = {};
772
936
  fields.forEach(f => {
773
- if (!forbiddenUnset.includes(f)) {
937
+ if (!this._props.forbiddenSet.includes(f)) {
774
938
  doc[f] = undefined;
775
939
  }
776
940
  });
@@ -782,11 +946,10 @@ class DbRepo {
782
946
  /** @inheritDoc */
783
947
  remove(k1, p1) {
784
948
  return __awaiter(this, void 0, void 0, function* () {
785
- const { conn } = this._props;
786
- const opt = conn.buildOpt(p1, 'remove');
949
+ const opt = this.buildOpt(p1, 'remove');
787
950
  const [key, field] = this._checkKey(k1);
788
951
  switch (field) {
789
- case "_urn":
952
+ case "urn":
790
953
  return this.removeByPrimary(key, opt, true);
791
954
  case "id":
792
955
  return this.removeBySecondary(key, opt, true);
@@ -798,18 +961,17 @@ class DbRepo {
798
961
  /** @inheritDoc */
799
962
  removeByPrimary(key, p1, ignoreCheck) {
800
963
  return __awaiter(this, void 0, void 0, function* () {
801
- const { cache, noRemove, conn } = this._props;
802
- const opt = conn.buildOpt(p1, 'removeByPrimary');
964
+ const opt = this.buildOpt(p1, 'removeByPrimary');
803
965
  const param = { where: 'DbRepo', method: 'removeByPrimary', queryName: opt.name };
804
- if (noRemove) {
966
+ if (this.isNoRemove) {
805
967
  throw new error_1.DbNotSupportedError('Remove', param);
806
968
  }
807
969
  if (!ignoreCheck) {
808
970
  (0, type_1.assertText)(key, Object.assign({ field: 'key' }, param));
809
971
  }
810
972
  const removedKey = yield this.$removeByPrimary(key, opt, true);
811
- if (removedKey && !opt.noCache && cache.props.isConnected) {
812
- cache.clearDoc(removedKey, opt)
973
+ if (removedKey && !opt.noCache && this.cache.isConnected) {
974
+ this.cache.clearDoc(removedKey, opt)
813
975
  .then()
814
976
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'removeByPrimary', 'cache', 'clearDoc')));
815
977
  }
@@ -819,24 +981,23 @@ class DbRepo {
819
981
  /** @inheritDoc */
820
982
  removeBySecondary(key, p1, ignoreCheck) {
821
983
  return __awaiter(this, void 0, void 0, function* () {
822
- const { cache, noRemove, useNumericId, idSame, conn } = this._props;
823
- const opt = conn.buildOpt(p1, 'removeBySecondary');
984
+ const opt = this.buildOpt(p1, 'removeBySecondary');
824
985
  const param = { where: 'DbRepo', method: 'removeByPrimary', queryName: opt.name };
825
- if (noRemove) {
986
+ if (this.isNoRemove) {
826
987
  throw new error_1.DbNotSupportedError('Remove', param);
827
988
  }
828
- if (useNumericId) {
989
+ if (this.hasNumericId) {
829
990
  (0, type_1.assertInteger)(key, { field: 'key', param });
830
991
  }
831
992
  else {
832
993
  (0, type_1.assertText)(key, { field: 'key', param });
833
994
  }
834
- if (idSame) {
995
+ if (this.isIdSame) {
835
996
  return this.removeByPrimary(this._keyToUrn(key), opt, ignoreCheck);
836
997
  }
837
998
  const removedKey = yield this.$removeBySecondary(key, opt, true);
838
- if (removedKey && !opt.noCache && cache.props.isConnected) {
839
- cache.clearDoc(removedKey, opt)
999
+ if (removedKey && !opt.noCache && this.cache.isConnected) {
1000
+ this.cache.clearDoc(removedKey, opt)
840
1001
  .then()
841
1002
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'removeBySecondary', 'cache', 'clearDoc')));
842
1003
  }
@@ -848,11 +1009,10 @@ class DbRepo {
848
1009
  /** @inheritDoc */
849
1010
  trash(k1, p1) {
850
1011
  return __awaiter(this, void 0, void 0, function* () {
851
- const { conn } = this._props;
852
- const opt = conn.buildOpt(p1, 'trash');
1012
+ const opt = this.buildOpt(p1, 'trash');
853
1013
  const [key, field] = this._checkKey(k1);
854
1014
  switch (field) {
855
- case "_urn":
1015
+ case "urn":
856
1016
  return this.trashByPrimary(key, opt, true);
857
1017
  case "id":
858
1018
  return this.trashBySecondary(key, opt, true);
@@ -864,13 +1024,12 @@ class DbRepo {
864
1024
  /** @inheritDoc */
865
1025
  trashByPrimary(key, p1, ignoreCheck) {
866
1026
  return __awaiter(this, void 0, void 0, function* () {
867
- const { noTrash, useSoftDelete, conn, cache } = this._props;
868
- const opt = conn.buildOpt(p1, 'trashByPrimary');
1027
+ const opt = this.buildOpt(p1, 'trashByPrimary');
869
1028
  const param = { where: 'DbRepo', method: 'trashByPrimary', queryName: opt.name };
870
- if (!useSoftDelete) {
1029
+ if (!this.hasSoftDelete) {
871
1030
  throw new error_1.DbNotSupportedError('Soft Delete', param);
872
1031
  }
873
- if (noTrash) {
1032
+ if (this.isNoTrash) {
874
1033
  throw new error_1.DbNotSupportedError('Trash', param);
875
1034
  }
876
1035
  if (!ignoreCheck) {
@@ -880,8 +1039,8 @@ class DbRepo {
880
1039
  opt.trashId = (0, node_crypto_1.randomUUID)();
881
1040
  }
882
1041
  const trashedKey = yield this.$trashByPrimary(key, opt, true);
883
- if (trashedKey && !opt.noCache && cache.props.isConnected) {
884
- cache.clearDoc(trashedKey, opt)
1042
+ if (trashedKey && !opt.noCache && this.cache.isConnected) {
1043
+ this.cache.clearDoc(trashedKey, opt)
885
1044
  .then()
886
1045
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'trashByPrimary', 'cache', 'clearDoc')));
887
1046
  }
@@ -891,30 +1050,29 @@ class DbRepo {
891
1050
  /** @inheritDoc */
892
1051
  trashBySecondary(key, p1, ignoreCheck) {
893
1052
  return __awaiter(this, void 0, void 0, function* () {
894
- const { noTrash, useSoftDelete, useNumericId, idSame, conn, cache } = this._props;
895
- const opt = conn.buildOpt(p1, 'trashBySecondary');
1053
+ const opt = this.buildOpt(p1, 'trashBySecondary');
896
1054
  const param = { where: 'DbRepo', method: 'trashBySecondary', queryName: opt.name };
897
- if (!useSoftDelete) {
1055
+ if (!this.hasSoftDelete) {
898
1056
  throw new error_1.DbNotSupportedError('Soft Delete', param);
899
1057
  }
900
- if (noTrash) {
1058
+ if (this.isNoTrash) {
901
1059
  throw new error_1.DbNotSupportedError('Trash', param);
902
1060
  }
903
- if (useNumericId) {
1061
+ if (this.hasNumericId) {
904
1062
  (0, type_1.assertInteger)(key, Object.assign({ field: 'key' }, param));
905
1063
  }
906
1064
  else {
907
1065
  (0, type_1.assertText)(key, Object.assign({ field: 'key' }, param));
908
1066
  }
909
- if (idSame) {
1067
+ if (this.isIdSame) {
910
1068
  return this.trashByPrimary(this._keyToUrn(key), opt, ignoreCheck);
911
1069
  }
912
1070
  if (!(0, type_1.isText)(opt.trashId)) {
913
1071
  opt.trashId = (0, node_crypto_1.randomUUID)();
914
1072
  }
915
1073
  const trashedKey = yield this.$trashBySecondary(key, opt, true);
916
- if (trashedKey && !opt.noCache && cache.props.isConnected) {
917
- cache.clearDoc(trashedKey, opt)
1074
+ if (trashedKey && !opt.noCache && this.cache.isConnected) {
1075
+ this.cache.clearDoc(trashedKey, opt)
918
1076
  .then()
919
1077
  .catch(e => this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'trashBySecondary', 'cache', 'clearDoc')));
920
1078
  }