@samet-it/be-db-common 1.1.1 → 1.1.3

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.
@@ -1,12 +1,11 @@
1
- import type { DbConnectionLike, DbExecOpt, DbQueryResultMore, DbQueryResultOne, DbConnOpt, DbMeta, DbOnAfter, DbConnProps } from "./index.types";
1
+ import { DbConnectionLike, DbExecOpt, DbQueryResultMore, DbQueryResultOne, DbConnOpt, DbMeta, DbOnAfter, DbConnProps, DbRepoLink, DbEvent } from "./index.types";
2
2
  import { LoggerLike } from "@samet-it/be-base-common";
3
3
  import type { DbLines } from "../line";
4
- import type { DbRepoDef } from "../repo";
5
4
  import type { Opt } from "@leyyo/common";
6
5
  /**
7
6
  * DB connection abstract class
8
7
  * */
9
- export declare abstract class DbConnection<REPO extends DbRepoDef, META extends DbMeta, OPT extends DbExecOpt> implements DbConnectionLike<REPO, META, OPT> {
8
+ export declare abstract class DbConnection<LINK extends DbRepoLink, META extends DbMeta, OPT extends DbExecOpt> implements DbConnectionLike<LINK, META, OPT> {
10
9
  /**
11
10
  * Logger
12
11
  * */
@@ -32,12 +31,34 @@ export declare abstract class DbConnection<REPO extends DbRepoDef, META extends
32
31
  * @see _opt
33
32
  * */
34
33
  protected _props: DbConnProps;
34
+ /**
35
+ * Constructor
36
+ *
37
+ * @param {DbConnOpt} opt - options
38
+ * */
35
39
  protected constructor(opt?: DbConnOpt);
36
- checkError(err: Error, opt: DbExecOpt | Opt): void;
37
- protected _on(items: Array<DbOnAfter>, fn: DbOnAfter, throwable: boolean): void;
40
+ /**
41
+ * Add or instantly trigger new lambda
42
+ *
43
+ * @param {DbEvent} name - event name
44
+ * @param {Array<function>} items - existing callback function array
45
+ * @param {function} fn - callback function
46
+ * @param {boolean?} throwable - throw an error if it fails
47
+ * */
48
+ protected _on(name: DbEvent, items: Array<DbOnAfter>, fn: DbOnAfter, throwable: boolean): void;
49
+ /**
50
+ * Trigger after on case
51
+ *
52
+ * @param {DbEvent} name - event name
53
+ * @param {Array<DbOnAfter>} items - callback functions
54
+ * @param {boolean} throwable - throwable? yes: throw the error
55
+ * */
56
+ protected _triggerOnCase(name: DbEvent, items: Array<DbOnAfter>, throwable: boolean): void;
38
57
  /** {@inheritDoc} */
39
58
  get props(): Readonly<DbConnProps>;
40
59
  /** {@inheritDoc} */
60
+ checkError(err: Error, opt: DbExecOpt | Opt): void;
61
+ /** {@inheritDoc} */
41
62
  f(field: string): string;
42
63
  /** {@inheritDoc} */
43
64
  abstract field(field: string): string;
@@ -60,9 +81,9 @@ export declare abstract class DbConnection<REPO extends DbRepoDef, META extends
60
81
  /** {@inheritDoc} */
61
82
  exec<T>(fn: Promise<T>, p1?: string | Omit<OPT, 'printSql'>): Promise<T>;
62
83
  /** {@inheritDoc} */
63
- abstract more<T>(repo: REPO, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultMore<T, META>>;
84
+ abstract more<T>(link: LINK, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultMore<T, META>>;
64
85
  /** {@inheritDoc} */
65
- abstract one<T>(repo: REPO, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultOne<T, META>>;
86
+ abstract one<T>(link: LINK, sql: string | DbLines, name?: string | DbExecOpt): Promise<DbQueryResultOne<T, META>>;
66
87
  /**
67
88
  * It will be called during module based systems
68
89
  * */
@@ -19,6 +19,11 @@ const error_1 = require("../error");
19
19
  * */
20
20
  class DbConnection {
21
21
  // endregion protected-property
22
+ /**
23
+ * Constructor
24
+ *
25
+ * @param {DbConnOpt} opt - options
26
+ * */
22
27
  constructor(opt) {
23
28
  /**
24
29
  * On connected callbacks
@@ -46,29 +51,15 @@ class DbConnection {
46
51
  delete this._opt;
47
52
  }
48
53
  // region protected-method
49
- checkError(err, opt) {
50
- var _a, _b, _c;
51
- const size = be_base_common_1.errorHandler.addStat(err);
52
- if ((_a = opt === null || opt === void 0 ? void 0 : opt.ignoredErrors) === null || _a === void 0 ? void 0 : _a.includes(err.name)) {
53
- return;
54
- }
55
- if (opt === null || opt === void 0 ? void 0 : opt.silent) {
56
- if (size < 100) {
57
- this.logger.warn(`[${size}] ${(_b = opt.name) !== null && _b !== void 0 ? _b : 'Database error'} <${err.name}> ${err.message}`, err);
58
- }
59
- return;
60
- }
61
- if (size < 100) {
62
- this.logger.error(`[${size}] ${(_c = opt.name) !== null && _c !== void 0 ? _c : 'Database error'} <${err.name}> ${err.message}`, err);
63
- }
64
- if (err instanceof error_1.DbError) {
65
- throw err;
66
- }
67
- else {
68
- throw be_base_common_1.errorHandler.common.castForClass(error_1.DbError, err, { queryName: opt.name });
69
- }
70
- }
71
- _on(items, fn, throwable) {
54
+ /**
55
+ * Add or instantly trigger new lambda
56
+ *
57
+ * @param {DbEvent} name - event name
58
+ * @param {Array<function>} items - existing callback function array
59
+ * @param {function} fn - callback function
60
+ * @param {boolean?} throwable - throw an error if it fails
61
+ * */
62
+ _on(name, items, fn, throwable) {
72
63
  if (typeof fn !== 'function') {
73
64
  return;
74
65
  }
@@ -77,13 +68,32 @@ class DbConnection {
77
68
  }
78
69
  else {
79
70
  fn().then().catch(e => {
80
- this.logger.error(`[${e.name}] => ${e.message}`, e);
71
+ this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'on', name));
81
72
  if (throwable) {
82
73
  throw e;
83
74
  }
84
75
  });
85
76
  }
86
77
  }
78
+ /**
79
+ * Trigger after on case
80
+ *
81
+ * @param {DbEvent} name - event name
82
+ * @param {Array<DbOnAfter>} items - callback functions
83
+ * @param {boolean} throwable - throwable? yes: throw the error
84
+ * */
85
+ _triggerOnCase(name, items, throwable) {
86
+ if (items.length > 0) {
87
+ items.forEach(fn => {
88
+ fn().then().catch(e => {
89
+ this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'trigger', 'on', name));
90
+ if (throwable) {
91
+ throw e;
92
+ }
93
+ });
94
+ });
95
+ }
96
+ }
87
97
  // endregion protected-method
88
98
  // region getter
89
99
  /** {@inheritDoc} */
@@ -93,6 +103,29 @@ class DbConnection {
93
103
  // endregion getter
94
104
  // region field-value
95
105
  /** {@inheritDoc} */
106
+ checkError(err, opt) {
107
+ var _a, _b, _c;
108
+ const size = be_base_common_1.errorHandler.addStat(err);
109
+ if ((_a = opt === null || opt === void 0 ? void 0 : opt.ignoredErrors) === null || _a === void 0 ? void 0 : _a.includes(err.name)) {
110
+ return;
111
+ }
112
+ if (opt === null || opt === void 0 ? void 0 : opt.silent) {
113
+ if (size < 100) {
114
+ this.logger.warn(be_base_common_1.errorHandler.common.logText(err, ((_b = opt.name) !== null && _b !== void 0 ? _b : 'Database error'), size));
115
+ }
116
+ return;
117
+ }
118
+ if (size < 100) {
119
+ this.logger.error(be_base_common_1.errorHandler.common.logText(err, ((_c = opt.name) !== null && _c !== void 0 ? _c : 'Database error'), size));
120
+ }
121
+ if (err instanceof error_1.DbError) {
122
+ throw err;
123
+ }
124
+ else {
125
+ throw be_base_common_1.errorHandler.common.castForClass(error_1.DbError, err, { queryName: opt.name });
126
+ }
127
+ }
128
+ /** {@inheritDoc} */
96
129
  f(field) {
97
130
  return this.field(field);
98
131
  }
@@ -135,15 +168,15 @@ class DbConnection {
135
168
  // region callback
136
169
  /** {@inheritDoc} */
137
170
  onConnected(fn) {
138
- this._on(this._onConnected, fn, false);
171
+ this._on('connected', this._onConnected, fn, false);
139
172
  }
140
173
  /** {@inheritDoc} */
141
174
  onDisconnected(fn) {
142
- this._on(this._onDisconnected, fn, false);
175
+ this._on('disconnected', this._onDisconnected, fn, false);
143
176
  }
144
177
  /** {@inheritDoc} */
145
178
  onFirstConnected(fn) {
146
- this._on(this._onFirstConnected, fn, true);
179
+ this._on('first-connected', this._onFirstConnected, fn, true);
147
180
  }
148
181
  // endregion callback
149
182
  // region query
@@ -1,7 +1,6 @@
1
1
  import type { DbLines } from "../line";
2
- import type { DbRepoDef } from "../repo";
3
2
  import type { DbErrorOmit } from "../error";
4
- import { Opt } from "@leyyo/common";
3
+ import type { Opt } from "@leyyo/common";
5
4
  /**
6
5
  * DB query result
7
6
  * */
@@ -129,7 +128,7 @@ export interface DbConnectionBase<OPT extends DbExecOpt = DbExecOpt> {
129
128
  /**
130
129
  * DB connection interface
131
130
  * */
132
- export interface DbConnectionLike<REPO extends DbRepoDef, META extends DbMeta, OPT extends DbExecOpt> extends DbConnectionBase {
131
+ export interface DbConnectionLike<LINK extends DbRepoLink, META extends DbMeta, OPT extends DbExecOpt> extends DbConnectionBase {
133
132
  /**
134
133
  * Props on connection
135
134
  * */
@@ -171,23 +170,23 @@ export interface DbConnectionLike<REPO extends DbRepoDef, META extends DbMeta, O
171
170
  /**
172
171
  * Execute a sql and return rows
173
172
  *
174
- * @param {DbRepoLike} repo - repository instance
173
+ * @param {DbRepoLink} link - repository link
175
174
  * @param {(string|DbLines)} sql - sql or sql lines
176
175
  * @param {(DbExecOpt|string)?} opt - option or query name
177
176
  * @return {Promise<DbQueryResultMore>} - rows
178
177
  * @async
179
178
  * */
180
- more<T>(repo: REPO, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultMore<T, META>>;
179
+ more<T>(link: LINK, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultMore<T, META>>;
181
180
  /**
182
181
  * Execute a sql and return a row
183
182
  *
184
- * @param {DbRepoLike} repo - repository instance
183
+ * @param {DbRepoLink} link - repository link
185
184
  * @param {(string|DbLines)} sql - sql or sql lines
186
185
  * @param {(DbExecOpt|string)?} opt - option or query name
187
186
  * @return {Promise<DbQueryResultOne>} - row
188
187
  * @async
189
188
  * */
190
- one<T>(repo: REPO, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultOne<T, META>>;
189
+ one<T>(link: LINK, sql: string | DbLines, opt?: string | OPT): Promise<DbQueryResultOne<T, META>>;
191
190
  /**
192
191
  * It will be called during module based systems
193
192
  *
@@ -292,3 +291,7 @@ export type DbOnAfter = () => Promise<void>;
292
291
  * DB connection events
293
292
  * */
294
293
  export type DbEvent = 'connected' | 'disconnected' | 'first-connected';
294
+ /** Repository Link */
295
+ export interface DbRepoLink {
296
+ path: string;
297
+ }
@@ -1,5 +1,14 @@
1
1
  import type { Opt } from "@leyyo/common";
2
2
  import { DbError } from "./db.error";
3
+ /**
4
+ * DB execute error during run sql
5
+ * */
3
6
  export declare class DbExecuteError extends DbError {
4
- constructor(err: Error, name: string, sql: string, opt?: Opt);
7
+ /**
8
+ * @param {Error} err - error instance
9
+ * @param {string} name - query name
10
+ * @param {string} sql - sql script
11
+ * @param {Opt} params - parameters
12
+ * */
13
+ constructor(err: Error, name: string, sql: string, params?: Opt);
5
14
  }
@@ -2,9 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DbExecuteError = void 0;
4
4
  const db_error_1 = require("./db.error");
5
+ // noinspection JSUnusedGlobalSymbols
6
+ /**
7
+ * DB execute error during run sql
8
+ * */
5
9
  class DbExecuteError extends db_error_1.DbError {
6
- constructor(err, name, sql, opt) {
7
- super(`${name ? name + ' : ' : ''}<${err.name}> ${err.message}`, Object.assign(Object.assign({}, opt), { sql, sqlName: name }));
10
+ /**
11
+ * @param {Error} err - error instance
12
+ * @param {string} name - query name
13
+ * @param {string} sql - sql script
14
+ * @param {Opt} params - parameters
15
+ * */
16
+ constructor(err, name, sql, params) {
17
+ super(`${name ? name + ' : ' : ''}<${err.name}> ${err.message}`, Object.assign(Object.assign({}, params), { sql, queryName: name }));
8
18
  }
9
19
  }
10
20
  exports.DbExecuteError = DbExecuteError;
@@ -1,5 +1,14 @@
1
1
  import type { BasicType } from "@leyyo/common";
2
2
  import { DbError } from "./db.error";
3
+ /**
4
+ * Cache validation error
5
+ * */
3
6
  export declare class DbInvalidValueError extends DbError {
4
- constructor(field: string, type: BasicType, where: string, method: string);
7
+ /**
8
+ * @param {string} field - invalid field
9
+ * @param {string} expected - expected type
10
+ * @param {string} where - class name
11
+ * @param {string} method - method name
12
+ * */
13
+ constructor(field: string, expected: BasicType, where: string, method: string);
5
14
  }
@@ -2,9 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DbInvalidValueError = void 0;
4
4
  const db_error_1 = require("./db.error");
5
+ // noinspection JSUnusedGlobalSymbols
6
+ /**
7
+ * Cache validation error
8
+ * */
5
9
  class DbInvalidValueError extends db_error_1.DbError {
6
- constructor(field, type, where, method) {
7
- super(`${field} value is not valid at ${where}#${method}`, { field, type, where, method });
10
+ /**
11
+ * @param {string} field - invalid field
12
+ * @param {string} expected - expected type
13
+ * @param {string} where - class name
14
+ * @param {string} method - method name
15
+ * */
16
+ constructor(field, expected, where, method) {
17
+ super(`${field} value is not valid at ${where}#${method}`, { field, expected, where, method });
8
18
  }
9
19
  }
10
20
  exports.DbInvalidValueError = DbInvalidValueError;
@@ -1,4 +1,12 @@
1
1
  import { DbError } from "./db.error";
2
+ /**
3
+ * DB not-supported error
4
+ * */
2
5
  export declare class DbNotSupportedError extends DbError {
6
+ /**
7
+ * @param {string} feature - feature name
8
+ * @param {string} where - class name
9
+ * @param {string} method - method name
10
+ * */
3
11
  constructor(feature: string, where: string, method: string);
4
12
  }
@@ -2,7 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DbNotSupportedError = void 0;
4
4
  const db_error_1 = require("./db.error");
5
+ /**
6
+ * DB not-supported error
7
+ * */
5
8
  class DbNotSupportedError extends db_error_1.DbError {
9
+ /**
10
+ * @param {string} feature - feature name
11
+ * @param {string} where - class name
12
+ * @param {string} method - method name
13
+ * */
6
14
  constructor(feature, where, method) {
7
15
  super(`${feature} is not supported at ${where}#${method}`, { feature, where, method });
8
16
  }
@@ -1,7 +1,7 @@
1
1
  import { SametError } from "@samet-it/be-base-common";
2
2
  import type { DbErrorOmit } from "./index.types";
3
3
  /**
4
- * Generic database error
4
+ * General database error
5
5
  * */
6
6
  export declare class DbError extends SametError implements DbErrorOmit {
7
7
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DbError = void 0;
4
4
  const be_base_common_1 = require("@samet-it/be-base-common");
5
5
  /**
6
- * Generic database error
6
+ * General database error
7
7
  * */
8
8
  class DbError extends be_base_common_1.SametError {
9
9
  }
@@ -1,12 +1,24 @@
1
- import type { DbCheckKeysResult, DbRepoProps, DbRepoLike, DbRepoOpt, DbRepoDef, DbCheckKeysTuple } from "./index.types";
2
- import type { DefDims, Entity, IdDocLike, LoggerLike, Pair, Portion, UrnDocLike, UrnTuple, View } from "@samet-it/be-base-common";
1
+ import type { DbCheckKeysResult, DbRepoProps, DbRepoLike, DbRepoOpt, DbCheckKeysTuple } from "./index.types";
2
+ import { DefDims, Entity, IdDocLike, LoggerLike, Pair, Portion, UrnDocLike, UrnTuple, View } from "@samet-it/be-base-common";
3
3
  import type { DbConnectionBase, DbExecOpt } from "../connection";
4
4
  import type { KeyValue, StrKey } from "@leyyo/common";
5
5
  import { type QueryAny, type QueryRegular } from "@leyyo/query";
6
6
  /**
7
7
  * DB repository abstract class
8
+ *
9
+ * Generics:
10
+ * - 0-`CONN`: db connection {@link DbConnectionBase}
11
+ * - 1-`OPT`: db execution options {@link DbExecOpt}
12
+ * - 2-`ENT`: entity {@link Entity}
13
+ * - 3-`ID`: id type {@link KeyValue}
14
+ * - 4-`URN`: urn interface {@link UrnDocLike}
15
+ * - 5-`VIEW`: view interface for presentation layer {@link View}
16
+ * - 6-`PAIR`: pair interface for presentation layer {@link Pair}
17
+ * - 7-`PORTION`: portion interface for presentation layer {@link Portion}
18
+ * - 8-`KEYS`: keys to autocomplete, def: keys of {@link Entity}
19
+ * - 9-`DIMS`: dimensions for presentation layer {@link DefDims}
8
20
  * */
9
- export declare abstract class DbRepo<CONN extends DbConnectionBase, OPT extends DbExecOpt, ID extends KeyValue, ENTITY extends Entity<ID>, URN extends UrnDocLike, KEYS extends string, DIMS extends DefDims, PAIR extends Pair<ID>, VIEW extends View<ID>, PORTION extends Portion<ID>> implements DbRepoLike<CONN, OPT, ID, ENTITY, URN, KEYS, DIMS, PAIR, VIEW, PORTION> {
21
+ export declare abstract class DbRepo<CONN extends DbConnectionBase, OPT extends DbExecOpt, ENT extends Entity<ID>, ID extends KeyValue, URN extends UrnDocLike, VIEW extends View<ID>, PAIR extends Pair<ID>, PORTION extends Portion<ID>, KEYS extends string, DIMS extends DefDims> implements DbRepoLike<CONN, OPT, ENT, ID, URN, VIEW, PAIR, PORTION, KEYS, DIMS> {
10
22
  /**
11
23
  * Logger
12
24
  * */
@@ -14,49 +26,53 @@ export declare abstract class DbRepo<CONN extends DbConnectionBase, OPT extends
14
26
  /**
15
27
  * Option of in-body usage in place of constructor param
16
28
  * */
17
- protected _opt: DbRepoOpt<ID, ENTITY>;
29
+ protected _opt: DbRepoOpt<ENT, ID>;
18
30
  /**
19
31
  * Produced setting from option
20
32
  * @see _opt
21
33
  * */
22
- protected _props: DbRepoProps<CONN, ID, ENTITY>;
23
- protected constructor(conn: CONN, opt?: DbRepoOpt<ID, ENTITY>);
24
- protected _removeFieldForForbidden(fields: Array<keyof ENTITY>, flag: keyof DbRepoOpt<ID, ENTITY>, field: keyof ENTITY): void;
25
- protected _checkForbiddenList(given: Array<keyof ENTITY>, def: Array<keyof ENTITY>): Array<keyof ENTITY>;
34
+ protected _props: DbRepoProps<CONN, ENT, ID>;
35
+ /**
36
+ * Constructor
37
+ *
38
+ * @param {DbConnectionBase} conn - db connection
39
+ * @param {DbRepoOpt} opt - options
40
+ * */
41
+ protected constructor(conn: CONN, opt?: DbRepoOpt<ENT, ID>);
42
+ protected _removeFieldForForbidden(fields: Array<keyof ENT>, flag: keyof DbRepoOpt<ENT, ID>, field: keyof ENT): void;
43
+ protected _checkForbiddenList(given: Array<keyof ENT>, def: Array<keyof ENT>): Array<keyof ENT>;
26
44
  protected get _now(): string | number;
27
45
  protected get _randomIndexName(): string;
28
46
  protected _indexName(name: string): string;
29
47
  /**
30
48
  * Fetch urn from doc as doc._urn
31
49
  * */
32
- protected _urnFromDoc(doc: Partial<ENTITY>, method: string): string;
50
+ protected _urnFromDoc(doc: Partial<ENT>, method: string): string;
33
51
  protected _checkKey(value: unknown): DbCheckKeysTuple<ID>;
34
52
  /**
35
53
  * Check array keys as id list or urn list
36
54
  * */
37
55
  protected _checkKeys(keys: Array<KeyValue>): DbCheckKeysResult<ID>;
38
56
  protected _isUrn(key: KeyValue): boolean;
57
+ protected _keyToUrn(key: KeyValue): string;
39
58
  /** @inheritDoc */
40
- get props(): Readonly<DbRepoProps<CONN, ID, ENTITY>>;
41
- /** @inheritDoc */
42
- get $def(): DbRepoDef;
59
+ get props(): Readonly<DbRepoProps<CONN, ENT, ID>>;
43
60
  /** @inheritDoc */
44
61
  $cast<T>(): T;
45
- protected _keyToUrn(key: KeyValue): string;
46
62
  /** @inheritDoc */
47
63
  toUrn(urnRec: URN): string;
48
64
  /** @inheritDoc */
49
65
  $toUrnTuple(urnRec: URN): UrnTuple;
50
66
  /** @inheritDoc */
51
- get(k1: KeyValue, p1?: OPT | string): Promise<ENTITY | undefined>;
67
+ get(k1: KeyValue, p1?: OPT | string): Promise<ENT | undefined>;
52
68
  /** @inheritDoc */
53
- getByPrimary(key: string, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
69
+ getByPrimary(key: string, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
54
70
  /** @inheritDoc */
55
- abstract $getByPrimary(key: string, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
71
+ abstract $getByPrimary(key: string, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
56
72
  /** @inheritDoc */
57
- getBySecondary(key: KeyValue, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
73
+ getBySecondary(key: KeyValue, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
58
74
  /** @inheritDoc */
59
- abstract $getBySecondary(key: KeyValue, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
75
+ abstract $getBySecondary(key: KeyValue, p1?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
60
76
  /** @inheritDoc */
61
77
  exists(k1: KeyValue, p1?: OPT | string): Promise<boolean>;
62
78
  /** @inheritDoc */
@@ -68,39 +84,43 @@ export declare abstract class DbRepo<CONN extends DbConnectionBase, OPT extends
68
84
  /** @inheritDoc */
69
85
  abstract $existsBySecondary(key: KeyValue, p1?: OPT | string, ignoreCheck?: boolean): Promise<boolean>;
70
86
  /** @inheritDoc */
71
- list(keys: Array<KeyValue>, p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENTITY>>;
87
+ list(keys: Array<KeyValue>, p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENT>>;
88
+ /** @inheritDoc */
89
+ abstract $listByPrimary(keys: string[], p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENT>>;
90
+ /** @inheritDoc */
91
+ abstract $listBySecondary(keys: Array<KeyValue>, p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENT>>;
72
92
  /** @inheritDoc */
73
- abstract $listByPrimary(keys: string[], p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENTITY>>;
93
+ filter<R = ENT, K2 extends string = StrKey<R>>(query: QueryAny<K2 | KEYS | StrKey<ENT>>, p1?: OPT | string): Promise<Array<R>>;
74
94
  /** @inheritDoc */
75
- abstract $listBySecondary(keys: Array<KeyValue>, p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENTITY>>;
95
+ abstract $filter<R = ENT, K2 extends string = StrKey<R>>(query: QueryRegular<K2 | KEYS | StrKey<ENT>>, p1?: OPT | string): Promise<Array<R>>;
76
96
  /** @inheritDoc */
77
- filter<R = ENTITY, K2 extends string = StrKey<R>>(query: QueryAny<K2 | KEYS | StrKey<ENTITY>>, p1?: OPT | string): Promise<Array<R>>;
97
+ insert(doc: ENT, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
78
98
  /** @inheritDoc */
79
- abstract $filter<R = ENTITY, K2 extends string = StrKey<R>>(query: QueryRegular<K2 | KEYS | StrKey<ENTITY>>, p1?: OPT | string): Promise<Array<R>>;
99
+ inserts(docs: Array<ENT>, p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<string>>;
80
100
  /** @inheritDoc */
81
- insert(doc: ENTITY, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
101
+ abstract $insert(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
82
102
  /** @inheritDoc */
83
- inserts(docs: Array<ENTITY>, p1?: OPT | string, ignoreCheck?: boolean): Promise<Array<string>>;
103
+ replace(doc: ENT, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
84
104
  /** @inheritDoc */
85
- abstract $insert(doc: ENTITY, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
105
+ abstract $replace(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
86
106
  /** @inheritDoc */
87
- replace(doc: ENTITY, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
107
+ upsert(doc: ENT, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
88
108
  /** @inheritDoc */
89
- abstract $replace(doc: ENTITY, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
109
+ abstract $upsert(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
90
110
  /** @inheritDoc */
91
- update(k1: KeyValue, doc: Partial<ENTITY>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
111
+ update(k1: KeyValue, doc: Partial<ENT>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
92
112
  /** @inheritDoc */
93
- updateByPrimary(key: string, doc: Partial<ENTITY>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
113
+ updateByPrimary(key: string, doc: Partial<ENT>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
94
114
  /** @inheritDoc */
95
- abstract $updateByPrimary(key: string, doc: Partial<ENTITY>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
115
+ abstract $updateByPrimary(key: string, doc: Partial<ENT>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
96
116
  /** @inheritDoc */
97
- updateBySecondary(key: KeyValue, doc: Partial<ENTITY>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
117
+ updateBySecondary(key: KeyValue, doc: Partial<ENT>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
98
118
  /** @inheritDoc */
99
- abstract $updateBySecondary(key: KeyValue, doc: Partial<ENTITY>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
119
+ abstract $updateBySecondary(key: KeyValue, doc: Partial<ENT>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
100
120
  /** @inheritDoc */
101
- set(key: KeyValue, doc: Partial<ENTITY>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
121
+ set(key: KeyValue, doc: Partial<ENT>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
102
122
  /** @inheritDoc */
103
- unset(key: KeyValue, fields: Array<keyof ENTITY | string>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
123
+ unset(key: KeyValue, fields: Array<keyof ENT | KEYS | string>, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
104
124
  /** @inheritDoc */
105
125
  remove(k1: KeyValue, p1?: OPT | string): Promise<string>;
106
126
  /** @inheritDoc */
@@ -122,24 +142,24 @@ export declare abstract class DbRepo<CONN extends DbConnectionBase, OPT extends
122
142
  /** @inheritDoc */
123
143
  abstract $trashBySecondary(key: KeyValue, p1?: OPT | string, ignoreCheck?: boolean): Promise<string>;
124
144
  /** @inheritDoc */
125
- $toDim<R extends IdDocLike<ID>>(doc: ENTITY, dim?: DIMS): Promise<R>;
145
+ $toDim<R extends IdDocLike<ID>>(doc: ENT, dim?: DIMS): Promise<R>;
126
146
  /** @inheritDoc */
127
147
  getDim<R extends IdDocLike<ID>>(key: KeyValue, dim?: DIMS): Promise<R>;
128
148
  /** @inheritDoc */
129
149
  listDims<R extends IdDocLike<ID>>(keys: Array<KeyValue>, dim?: DIMS, ignoreCheck?: boolean): Promise<Array<R>>;
130
150
  /** @inheritDoc */
131
- $toPair(doc: ENTITY): Promise<PAIR>;
151
+ $toPair(doc: ENT): Promise<PAIR>;
132
152
  /** @inheritDoc */
133
153
  getPair(key: KeyValue): Promise<PAIR>;
134
154
  /** @inheritDoc */
135
155
  listPairs(keys: Array<KeyValue>, ignoreCheck?: boolean): Promise<Array<PAIR>>;
136
- $toView(doc: ENTITY): Promise<VIEW>;
156
+ $toView(doc: ENT): Promise<VIEW>;
137
157
  /** @inheritDoc */
138
158
  getView(identifier: string): Promise<VIEW>;
139
159
  /** @inheritDoc */
140
160
  listViews(identifiers: Array<string>, ignoreCheck?: boolean): Promise<Array<VIEW>>;
141
161
  /** @inheritDoc */
142
- $toPortion(doc: ENTITY): Promise<PORTION>;
162
+ $toPortion(doc: ENT): Promise<PORTION>;
143
163
  /** @inheritDoc */
144
164
  getPortion(identifier: string): Promise<PORTION>;
145
165
  /** @inheritDoc */