taon 21.0.53 → 21.0.55

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.
Files changed (115) hide show
  1. package/bin/taon +5 -5
  2. package/bin/taon-debug +5 -5
  3. package/bin/taon-debug-brk +4 -4
  4. package/browser/package.json +1 -1
  5. package/browser-prod/package.json +1 -1
  6. package/icon-menu-taon.svg +15 -15
  7. package/lib/build-info._auto-generated_.d.ts +1 -1
  8. package/lib/build-info._auto-generated_.js +1 -1
  9. package/lib/package.json +1 -1
  10. package/lib/ui/index.js +2 -2
  11. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  12. package/lib-prod/base-classes/base-abstract-entity.js +17 -31
  13. package/lib-prod/base-classes/base-angular-service.js +83 -55
  14. package/lib-prod/base-classes/base-class.js +33 -35
  15. package/lib-prod/base-classes/base-context.js +17 -19
  16. package/lib-prod/base-classes/base-controller.js +146 -154
  17. package/lib-prod/base-classes/base-crud-controller.js +250 -221
  18. package/lib-prod/base-classes/base-custom-repository.js +7 -18
  19. package/lib-prod/base-classes/base-electron-service.js +49 -0
  20. package/lib-prod/base-classes/base-entity.js +20 -30
  21. package/lib-prod/base-classes/base-file-upload.middleware.js +72 -75
  22. package/lib-prod/base-classes/base-injector.js +176 -194
  23. package/lib-prod/base-classes/base-middleware.js +8 -5
  24. package/lib-prod/base-classes/base-migration.js +19 -22
  25. package/lib-prod/base-classes/base-provider.js +7 -5
  26. package/lib-prod/base-classes/base-repository.js +601 -573
  27. package/lib-prod/base-classes/base-subscriber-for-entity.js +143 -152
  28. package/lib-prod/base-classes/base.js +18 -0
  29. package/lib-prod/build-info._auto-generated_.js +26 -14
  30. package/lib-prod/config/controller-config.js +24 -24
  31. package/lib-prod/config/controller-options.js +2 -5
  32. package/lib-prod/config/method-config.js +6 -8
  33. package/lib-prod/config/param-config.js +2 -8
  34. package/lib-prod/constants.js +29 -25
  35. package/lib-prod/context-db-migrations.js +328 -324
  36. package/lib-prod/create-context.js +211 -146
  37. package/lib-prod/decorators/classes/controller-decorator.js +16 -20
  38. package/lib-prod/decorators/classes/entity-decorator.js +26 -47
  39. package/lib-prod/decorators/classes/middleware-decorator.js +14 -24
  40. package/lib-prod/decorators/classes/migration-decorator.js +13 -22
  41. package/lib-prod/decorators/classes/provider-decorator.js +13 -23
  42. package/lib-prod/decorators/classes/repository-decorator.js +13 -22
  43. package/lib-prod/decorators/classes/subscriber-decorator.js +13 -23
  44. package/lib-prod/decorators/decorator-abstract-opt.js +1 -4
  45. package/lib-prod/decorators/http/http-decorators.js +20 -5
  46. package/lib-prod/decorators/http/http-methods-decorators.js +91 -133
  47. package/lib-prod/decorators/http/http-params-decorators.js +36 -62
  48. package/lib-prod/dependency-injection/di-container.js +28 -29
  49. package/lib-prod/endpoint-context-storage.js +27 -32
  50. package/lib-prod/endpoint-context.js +2294 -1930
  51. package/lib-prod/entity-process.js +209 -198
  52. package/lib-prod/env/env.angular-node-app.js +66 -130
  53. package/lib-prod/env/env.docs-webapp.js +66 -130
  54. package/lib-prod/env/env.electron-app.js +66 -130
  55. package/lib-prod/env/env.mobile-app.js +66 -130
  56. package/lib-prod/env/env.npm-lib-and-cli-tool.js +66 -130
  57. package/lib-prod/env/env.vscode-plugin.js +66 -130
  58. package/lib-prod/env/index.js +6 -6
  59. package/lib-prod/express-types.js +1 -0
  60. package/lib-prod/formly/formly.models.js +1 -0
  61. package/lib-prod/formly/fromly.js +196 -175
  62. package/lib-prod/formly/type-from-entity.js +45 -52
  63. package/lib-prod/get-response-value.js +21 -18
  64. package/lib-prod/global-state/taon-global-state/index.js +6 -5
  65. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +18 -19
  66. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +6 -9
  67. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +40 -46
  68. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +33 -46
  69. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +10 -20
  70. package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +43 -33
  71. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +10 -20
  72. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +43 -44
  73. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +20 -27
  74. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +10 -10
  75. package/lib-prod/global-state/taon-transaction-registry/index.js +11 -10
  76. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +20 -21
  77. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +4 -7
  78. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +34 -39
  79. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +34 -54
  80. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +10 -20
  81. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -10
  82. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +10 -20
  83. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +29 -34
  84. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +20 -27
  85. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +4 -5
  86. package/lib-prod/helpers/class-helpers.js +210 -177
  87. package/lib-prod/helpers/clone-obj.js +16 -20
  88. package/lib-prod/helpers/taon-helpers.js +132 -114
  89. package/lib-prod/index._auto-generated_.js +5 -0
  90. package/lib-prod/index.js +248 -227
  91. package/lib-prod/inject.js +88 -33
  92. package/lib-prod/migrations/index.js +2 -1
  93. package/lib-prod/migrations/migrations_index._auto-generated_.js +3 -0
  94. package/lib-prod/models.js +72 -103
  95. package/lib-prod/orm/columns.js +58 -118
  96. package/lib-prod/orm/index.js +56 -1
  97. package/lib-prod/package.json +1 -1
  98. package/lib-prod/realtime/realtime-client.js +188 -186
  99. package/lib-prod/realtime/realtime-core.js +77 -78
  100. package/lib-prod/realtime/realtime-server.js +225 -240
  101. package/lib-prod/realtime/realtime-strategy/index.js +4 -4
  102. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +273 -219
  103. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +267 -240
  104. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +26 -20
  105. package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +10 -13
  106. package/lib-prod/realtime/realtime-subs-manager.js +82 -90
  107. package/lib-prod/realtime/realtime.models.js +2 -0
  108. package/lib-prod/symbols.js +104 -105
  109. package/lib-prod/ui/index.js +1 -5
  110. package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -5
  111. package/lib-prod/validators.js +43 -37
  112. package/lib-prod.split-namespaces.json +32 -86
  113. package/package.json +1 -1
  114. package/websql/package.json +1 -1
  115. package/websql-prod/package.json +1 -1
@@ -1,65 +1,58 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __decorateClass = (decorators, target, key, kind) => {
4
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
- if (decorator = decorators[i])
7
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
9
- return result;
10
- };
11
- import { MySqlQuerySource } from "taon-type-sql/lib-prod";
12
- import { Helpers__NS__warn } from "tnp-core/lib-prod";
13
- import { ___NS__isObject, ___NS__isUndefined, ___NS__lowerFirst } from "tnp-core/lib-prod";
14
- import { TaonRepository } from "../decorators/classes/repository-decorator";
15
- import { ClassHelpers__NS__getName } from "../helpers/class-helpers";
16
- import { TaonBaseCustomRepository } from "./base-custom-repository";
17
- const INDEX_KEYS_NO_FOR_UPDATE = ["id"];
18
- let TaonBaseRepository = class extends TaonBaseCustomRepository {
19
- REPOS_CACHE_KEY = Symbol("repository cache inside instance");
20
- constructor(__entityClassResolveFn) {
21
- super();
22
- this.entityClassResolveFn = __entityClassResolveFn;
23
- }
24
- //#endregion
25
- //#region db query
26
- __dbQuery;
27
- get dbQuery() {
28
- if (!this.__dbQuery) {
29
- if (!this.ctx) {
30
- return;
31
- throw new Error(
32
- `[TaonBaseRepository] Context not inited for class ${ClassHelpers__NS__getName(
33
- this
34
- )}`
35
- );
36
- }
37
- const connection = this.ctx?.connection;
38
- if (!connection) {
39
- throw new Error(
40
- `[TaonBaseRepository] Database not inited for context ${this.ctx?.contextName}`
41
- );
42
- }
43
- this.__dbQuery = new MySqlQuerySource(connection);
44
- }
45
- return this.__dbQuery;
46
- }
47
- //#endregion
48
- //#region connection
49
- get connection() {
50
- return this.ctx?.connection;
51
- }
52
- //#endregion
53
- //#region repository
54
- get repository() {
55
- if (this[this.REPOS_CACHE_KEY]) {
56
- return this[this.REPOS_CACHE_KEY];
57
- }
58
- const resolvedRepoClass = this.entityClassResolveFn();
59
- const resolvedRepoName = ClassHelpers__NS__getName(resolvedRepoClass);
60
- const repo = this.ctx.repos.get(resolvedRepoName);
61
- if (!repo) {
62
- throw `[TaonBaseRepository] Repository for entity "${resolvedRepoName}"
1
+ //#region imports
2
+ import { MySqlQuerySource } from 'taon-type-sql/lib-prod';
3
+ import { Helpers__NS__warn } from 'tnp-core/lib-prod';
4
+ import { ___NS__isObject, ___NS__isUndefined, ___NS__lowerFirst } from 'tnp-core/lib-prod';
5
+ import { TaonRepository } from '../decorators/classes/repository-decorator';
6
+ import { ClassHelpers__NS__getName } from '../helpers/class-helpers';
7
+ import { TaonBaseCustomRepository } from './base-custom-repository';
8
+ //#endregion
9
+ const INDEX_KEYS_NO_FOR_UPDATE = ['id'];
10
+ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomRepository {
11
+ constructor(
12
+ // Injected through TaonBaseCrudController
13
+ __entityClassResolveFn) {
14
+ super();
15
+ this.REPOS_CACHE_KEY = Symbol('repository cache inside instance');
16
+ this.allowedTypesToUpdate = ['simple-json', 'simple-array', 'json'];
17
+ // @ts-ignore
18
+ this.entityClassResolveFn = __entityClassResolveFn;
19
+ }
20
+ get dbQuery() {
21
+ //#region @websqlFunc
22
+ if (!this.__dbQuery) {
23
+ if (!this.ctx) {
24
+ return; // TODO
25
+ throw new Error(`[TaonBaseRepository] Context not inited for class ${ClassHelpers__NS__getName(this)}`);
26
+ }
27
+ const connection = this.ctx?.connection;
28
+ if (!connection) {
29
+ throw new Error(`[TaonBaseRepository] Database not inited for context ${this.ctx?.contextName}`);
30
+ }
31
+ this.__dbQuery = new MySqlQuerySource(connection);
32
+ }
33
+ return this.__dbQuery;
34
+ //#endregion
35
+ }
36
+ //#endregion
37
+ //#region connection
38
+ get connection() {
39
+ //#region @websqlFunc
40
+ return this.ctx?.connection;
41
+ //#endregion
42
+ }
43
+ //#endregion
44
+ //#region repository
45
+ get repository() {
46
+ //#region @websqlFunc
47
+ if (this[this.REPOS_CACHE_KEY]) {
48
+ return this[this.REPOS_CACHE_KEY];
49
+ }
50
+ const resolvedRepoClass = this.entityClassResolveFn();
51
+ const resolvedRepoName = ClassHelpers__NS__getName(resolvedRepoClass);
52
+ const repo = this.ctx.repos.get(resolvedRepoName);
53
+ // TODO better recognize what is class in context
54
+ if (!repo) {
55
+ throw `[TaonBaseRepository] Repository for entity "${resolvedRepoName}"
63
56
  not found in context "${this.ctx?.contextName}".
64
57
 
65
58
  Is ${resolvedRepoName} a Taon entity class ?
@@ -73,517 +66,552 @@ let TaonBaseRepository = class extends TaonBaseCustomRepository {
73
66
  ...
74
67
 
75
68
  `;
69
+ }
70
+ this[this.REPOS_CACHE_KEY] = repo;
71
+ return this[this.REPOS_CACHE_KEY];
72
+ //#endregion
73
+ }
74
+ /**
75
+ * target for repository
76
+ */
77
+ get target() {
78
+ //#region @websqlFunc
79
+ return this?.repository?.target;
80
+ //#endregion
81
+ }
82
+ /**
83
+ * alias to repository
84
+ */
85
+ get repo() {
86
+ //#region @websqlFunc
87
+ return this.repository;
88
+ //#endregion
89
+ }
90
+ get repositoryExists() {
91
+ //#region @websqlFunc
92
+ return !!this.repository;
93
+ //#endregion
94
+ }
95
+ //#endregion
96
+ //#region crud operations / typeorm / has id
97
+ /**
98
+ * Checks if entity has an id.
99
+ * If entity composite compose ids, it will check them all.
100
+ */
101
+ hasId(entity) {
102
+ return this.repo.hasId(entity);
103
+ }
104
+ //#endregion
105
+ //#region crud operations / typeorm / get id
106
+ /**
107
+ * Gets entity mixed id.
108
+ */
109
+ getId(entity) {
110
+ return this.repo.getId(entity);
111
+ }
112
+ //#endregion
113
+ //#region crud operations / typeorm / create & bulk create
114
+ /**
115
+ Saves a given entity in the database.
116
+ * If entity does not exist in the database then inserts, otherwise updates.
117
+ */
118
+ async save(item, options) {
119
+ //#region @websqlFunc
120
+ // if (!this.repo) {
121
+ // debugger;
122
+ // }
123
+ let model = await this.repo.create(item);
124
+ model = await this.repo.save(model, options);
125
+ const { id } = model;
126
+ model = await this.repo.findOne({
127
+ where: { id },
128
+ });
129
+ return model;
130
+ //#endregion
131
+ }
132
+ /**
133
+ * Creates a new entity instance or instances.
134
+ * Can copy properties from the given object into new entities.
135
+ */
136
+ create(plainEntityLikeOrPlainEntityLikes) {
137
+ return this.repo.create(plainEntityLikeOrPlainEntityLikes);
138
+ }
139
+ async bulkSave(items, options) {
140
+ //#region @websqlFunc
141
+ const models = [];
142
+ for (let index = 0; index < items.length; index++) {
143
+ const item = items[index];
144
+ // TODO FIX THIS / REFACTOR
145
+ const model = await this.save(item, options);
146
+ models.push(model);
147
+ }
148
+ return models;
149
+ //#endregion
150
+ }
151
+ /**
152
+ * @deprecated use bulkSave instead
153
+ */
154
+ async bulkCreate(items, options) {
155
+ return this.bulkSave(items, options);
156
+ }
157
+ //#region old typeorm version
158
+ /**
159
+ * Saves all given entities in the database.
160
+ * If entities do not exist in the database then inserts, otherwise updates.
161
+ */
162
+ // save<T extends DeepPartial<Entity>>(
163
+ // entities: T[],
164
+ // options: SaveOptions & {
165
+ // reload: false;
166
+ // },
167
+ // ): Promise<T[]>;
168
+ // /**
169
+ // * Saves all given entities in the database.
170
+ // * If entities do not exist in the database then inserts, otherwise updates.
171
+ // */
172
+ // save<T extends DeepPartial<Entity>>(
173
+ // entities: T[],
174
+ // options?: SaveOptions,
175
+ // ): Promise<(T & Entity)[]>;
176
+ // /**
177
+ // * Saves a given entity in the database.
178
+ // * If entity does not exist in the database then inserts, otherwise updates.
179
+ // */
180
+ // save<T extends DeepPartial<Entity>>(
181
+ // entity: T,
182
+ // options: SaveOptions & {
183
+ // reload: false;
184
+ // },
185
+ // ): Promise<T>;
186
+ // /**
187
+ // * Saves a given entity in the database.
188
+ // * If entity does not exist in the database then inserts, otherwise updates.
189
+ // */
190
+ // save<T extends DeepPartial<Entity>>(
191
+ // entity: T,
192
+ // options?: SaveOptions,
193
+ // ): Promise<T & Entity> {
194
+ // return this.repo.save(entity, options);
195
+ // }
196
+ //#endregion
197
+ //#endregion
198
+ //#region crud operations / typeorm / merge
199
+ /**
200
+ * Merges multiple entities (or entity-like objects) into a given entity.
201
+ */
202
+ merge(mergeIntoEntity, ...entityLikes) {
203
+ return this.repo.merge(mergeIntoEntity, ...entityLikes);
204
+ }
205
+ //#endregion
206
+ //#region crud operations / typeorm / preload
207
+ /**
208
+ * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
209
+ * it loads it (and everything related to it), replaces all values with the new ones from the given object
210
+ * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
211
+ * replaced from the new object.
212
+ *
213
+ * Note that given entity-like object must have an entity id / primary key to find entity by.
214
+ * Returns undefined if entity with given id was not found.
215
+ */
216
+ preload(entityLike) {
217
+ return this.repo.preload(entityLike);
218
+ }
219
+ //#endregion
220
+ //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
221
+ /**
222
+ * Removes a given entities from the database.
223
+ */
224
+ async remove(idOrEntity) {
225
+ //#region @websqlFunc
226
+ if (___NS__isObject(idOrEntity)) {
227
+ idOrEntity = idOrEntity.id;
228
+ }
229
+ const deletedEntity = await this.repo.findOne({
230
+ where: { id: idOrEntity },
231
+ });
232
+ if (!deletedEntity) {
233
+ Helpers__NS__warn(`[TaonBaseRepository] Entity "${ClassHelpers__NS__getName(this.repo.target)}" ` + `with id ${idOrEntity} not found, cannot remove`);
234
+ return;
235
+ }
236
+ const idCopy = deletedEntity.id;
237
+ await this.repo.remove(deletedEntity);
238
+ deletedEntity.id = idCopy;
239
+ return deletedEntity;
240
+ //#endregion
241
+ }
242
+ /**
243
+ * alias to remove
244
+ */
245
+ async delete(idOrEntity) {
246
+ return this.remove(idOrEntity);
247
+ }
248
+ /**
249
+ * alias to removeById
250
+ */
251
+ async deleteById(id) {
252
+ return this.remove(id);
253
+ }
254
+ async bulkRemove(idsOrEntities) {
255
+ //#region @websqlFunc
256
+ idsOrEntities = idsOrEntities.map(id => {
257
+ return ___NS__isObject(id) ? id.id : id;
258
+ });
259
+ const models = [];
260
+ for (let index = 0; index < idsOrEntities.length; index++) {
261
+ const id = idsOrEntities[index];
262
+ const model = await this.remove(id);
263
+ models.push(model);
264
+ }
265
+ return models;
266
+ //#endregion
267
+ }
268
+ async bulkDelete(ids) {
269
+ return this.bulkRemove(ids);
270
+ }
271
+ /**
272
+ * Records the delete date of a given entity.
273
+ */
274
+ softRemove(entity, options) {
275
+ return this.repo.softRemove(entity, options);
276
+ }
277
+ /**
278
+ * Recovers a given entity in the database.
279
+ */
280
+ recover(entity, options) {
281
+ return this.repo.recover(entity, options);
282
+ }
283
+ //#endregion
284
+ //#region crud operations / typeorm / insert
285
+ /**
286
+ * Inserts a given entity into the database.
287
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
288
+ * Executes fast and efficient INSERT query.
289
+ * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
290
+ */
291
+ insert(entity) {
292
+ // debugger;
293
+ return this.repo.insert(entity);
294
+ }
295
+ //#endregion
296
+ //#region crud operations / typeorm / update & build update
297
+ async update(item) {
298
+ //#region @websqlFunc
299
+ const { id } = item;
300
+ return await this.updateById(id, item);
301
+ //#endregion
302
+ }
303
+ async updateById(id, item) {
304
+ //#region @websqlFunc
305
+ const allowedPropsToUpdate = [];
306
+ for (const key in item) {
307
+ const metadataColumn = this.repo.metadata.ownColumns.find(c => c.propertyName === key);
308
+ if (___NS__isObject(item) &&
309
+ item.hasOwnProperty(key) &&
310
+ (typeof item[key] !== 'object' ||
311
+ this.allowedTypesToUpdate.includes(metadataColumn?.type)) &&
312
+ !___NS__isUndefined(metadataColumn)) {
313
+ allowedPropsToUpdate.push(key);
314
+ }
315
+ }
316
+ for (let i = 0; i < allowedPropsToUpdate.length; i++) {
317
+ const key = allowedPropsToUpdate[i];
318
+ if (!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) {
319
+ // const raw = ___NS__isBoolean(item[key]) || ___NS__isNumber(item[key]) || ___NS__isNull(item[key]); // TODO does this make any sense ?
320
+ const toSet = item[key];
321
+ // const tableName = tableNameFrom(this.entity as any);
322
+ await this.repo.update({
323
+ id,
324
+ }, {
325
+ [key]: toSet,
326
+ });
327
+ // await this.repo.query(
328
+ // `UPDATE '${tableName}' as ${table}
329
+ // SET ${key}=${toSet}
330
+ // WHERE ${table}.id='${id}'
331
+ // `);
332
+ }
333
+ }
334
+ let model = await this.repo.findOne({
335
+ where: { id },
336
+ });
337
+ return model;
338
+ //#endregion
339
+ }
340
+ async bulkUpdate(items) {
341
+ //#region @websqlFunc
342
+ const models = [];
343
+ for (let index = 0; index < items.length; index++) {
344
+ const item = items[index];
345
+ const { id } = item; // TOOD
346
+ const model = await this.updateById(id, item);
347
+ models.push(model);
348
+ }
349
+ return { models };
350
+ //#endregion
351
+ }
352
+ //#region tpeorm update version
353
+ // this version suck and will not return update entity
354
+ // /**
355
+ // * Updates entity partially. Entity can be found by a given conditions.
356
+ // * Unlike save method executes a primitive operation without cascades, relations and other operations included.
357
+ // * Executes fast and efficient UPDATE query.
358
+ // * Does not check if entity exist in the database.
359
+ // */
360
+ // update(
361
+ // criteria:
362
+ // | string
363
+ // | string[]
364
+ // | number
365
+ // | number[]
366
+ // | Date
367
+ // | Date[]
368
+ // | ObjectID
369
+ // | ObjectID[]
370
+ // | FindOptionsWhere<Entity>,
371
+ // partialEntity: QueryDeepPartialEntity<Entity>,
372
+ // ): Promise<UpdateResult> {
373
+ // return this.repo.update(criteria, partialEntity);
374
+ // }
375
+ //#endregion
376
+ //#endregion
377
+ //#region crud operations / typeorm / upsert
378
+ /**
379
+ * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
380
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
381
+ * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
382
+ */
383
+ upsert(entityOrEntities, conflictPathsOrOptions) {
384
+ return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
385
+ }
386
+ //#endregion
387
+ //#region crud operations / typeorm / soft delete
388
+ /**
389
+ * Records the delete date of entities by a given criteria.
390
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
391
+ * Executes fast and efficient SOFT-DELETE query.
392
+ * Does not check if entity exist in the database.
393
+ */
394
+ softDelete(criteria) {
395
+ return this.repo.softDelete(criteria);
396
+ }
397
+ //#endregion
398
+ //#region crud operations / typeorm / restore
399
+ /**
400
+ * Restores entities by a given criteria.
401
+ * Unlike save method executes a primitive operation without cascades, relations and other operations included.
402
+ * Executes fast and efficient SOFT-DELETE query.
403
+ * Does not check if entity exist in the database.
404
+ */
405
+ restore(criteria) {
406
+ return this.repo.restore(criteria);
407
+ }
408
+ //#endregion
409
+ //#region crud operations / typeorm / count
410
+ /**
411
+ * Counts entities that match given options.
412
+ * Useful for pagination.
413
+ */
414
+ count(options) {
415
+ return this.repo.count(options);
416
+ }
417
+ //#endregion
418
+ //#region crud operations / typeorm / count by
419
+ /**
420
+ * Counts entities that match given conditions.
421
+ * Useful for pagination.
422
+ */
423
+ countBy(where) {
424
+ return this.repo.countBy(where);
425
+ }
426
+ //#endregion
427
+ //#region crud operations / typeorm / find
428
+ /**
429
+ * Finds entities that match given find options.
430
+ */
431
+ find(options) {
432
+ return this.repo.find(options);
433
+ }
434
+ //#endregion
435
+ //#region crud operations / typeorm / find by
436
+ /**
437
+ * Finds entities that match given find options.
438
+ */
439
+ findBy(where) {
440
+ return this.repo.findBy(where);
441
+ }
442
+ //#endregion
443
+ //#region crud operations / typeorm / find and count
444
+ // async findAndCount(options: { take: number; skip: number }) {
445
+ // const { take, skip } = options;
446
+ // const [result, total] = await this.repo.findAndCount({
447
+ // // where: { name: Like('%' + keyword + '%') },
448
+ // // order: { name: "DESC" },
449
+ // take: take,
450
+ // skip: skip,
451
+ // });
452
+ // return { result, total };
453
+ // }
454
+ //
455
+ /**
456
+ * Finds entities that match given find options.
457
+ * Also counts all entities that match given conditions,
458
+ * but ignores pagination settings (from and take options).
459
+ */
460
+ findAndCount(options) {
461
+ return this.repo.findAndCount(options);
462
+ }
463
+ //#endregion
464
+ //#region crud operations / typeorm / find and count by
465
+ /**
466
+ * Finds entities that match given WHERE conditions.
467
+ * Also counts all entities that match given conditions,
468
+ * but ignores pagination settings (from and take options).
469
+ */
470
+ findAndCountBy(where) {
471
+ return this.repo.findAndCountBy(where);
472
+ }
473
+ //#endregion
474
+ //#region crud operations / typeorm / find by ids
475
+ /**
476
+ * Finds entities with ids.
477
+ * Optionally find options or conditions can be applied.
478
+ *
479
+ * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
480
+ *
481
+ * .findBy({
482
+ * id: In([1, 2, 3])
483
+ * })
484
+ */
485
+ findByIds(ids) {
486
+ return this.repo.findByIds(ids);
487
+ }
488
+ //#endregion
489
+ //#region crud operations / typeorm / find one
490
+ /**
491
+ * Finds first entity by a given find options.
492
+ * If entity was not found in the database - returns null.
493
+ */
494
+ findOne(options) {
495
+ return this.repo.findOne(options);
496
+ }
497
+ //#endregion
498
+ //#region crud operations / typeorm / find one by
499
+ /**
500
+ * Finds first entity that matches given where condition.
501
+ * If entity was not found in the database - returns null.
502
+ */
503
+ findOneBy(where) {
504
+ return this.repo.findOneBy(where);
505
+ }
506
+ //#endregion
507
+ //#region crud operations / typeorm / find one or fail
508
+ /**
509
+ * Finds first entity that matches given id.
510
+ * If entity was not found in the database - returns null.
511
+ *
512
+ * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
513
+ *
514
+ * .findOneBy({
515
+ * id: 1 // where "id" is your primary column name
516
+ * })
517
+ */
518
+ findOneById(id) {
519
+ return this.repo.findOneById(id);
520
+ }
521
+ //#endregion
522
+ //#region crud operations / typeorm / find one or fail
523
+ /**
524
+ * Finds first entity by a given find options.
525
+ * If entity was not found in the database - rejects with error.
526
+ */
527
+ findOneOrFail(options) {
528
+ return this.repo.findOneOrFail(options);
529
+ }
530
+ //#endregion
531
+ //#region crud operations / typeorm / find one by or fail
532
+ /**
533
+ * Finds first entity that matches given where condition.
534
+ * If entity was not found in the database - rejects with error.
535
+ */
536
+ findOneByOrFail(where) {
537
+ return this.repo.findOneByOrFail(where);
538
+ }
539
+ //#endregion
540
+ //#region crud operations / typeorm / query
541
+ /**
542
+ * Executes a raw SQL query and returns a raw database results.
543
+ * Raw query execution is supported only by relational databases (MongoDB is not supported).
544
+ */
545
+ query(query, parameters) {
546
+ return this.repo.query(query, parameters);
547
+ }
548
+ //#endregion
549
+ //#region crud operations / typeorm / query
550
+ /**
551
+ * Executes a raw SQL query and returns a raw database results.
552
+ * Raw query execution is supported only by relational databases (MongoDB is not supported).
553
+ */
554
+ createQueryBuilder(alias, queryRunner) {
555
+ return this.repo.createQueryBuilder(alias, queryRunner);
556
+ }
557
+ //#endregion
558
+ //#region crud operations / typeorm / clear
559
+ /**
560
+ * Clears all the data from the given table/collection (truncates/drops it).
561
+ *
562
+ * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
563
+ * @see https://stackoverflow.com/a/5972738/925151
564
+ */
565
+ clear() {
566
+ return this.repo.clear();
567
+ }
568
+ //#endregion
569
+ //#region crud operations / typeorm / increment
570
+ /**
571
+ * Increments some column by provided value of the entities matched given conditions.
572
+ */
573
+ increment(conditions, propertyPath, value) {
574
+ return this.repo.increment(conditions, propertyPath, value);
575
+ }
576
+ //#endregion
577
+ //#region crud operations / typeorm / decrement
578
+ /**
579
+ * Decrements some column by provided value of the entities matched given conditions.
580
+ */
581
+ decrement(conditions, propertyPath, value) {
582
+ return this.repo.decrement(conditions, propertyPath, value);
583
+ }
584
+ //#endregion
585
+ //#region crud operations / get all
586
+ /**
587
+ * @deprecated use findAndCount instead
588
+ */
589
+ async getAll() {
590
+ //#region @websqlFunc
591
+ // console.log('repo', this.__repository);
592
+ // console.log(
593
+ // `repo taget name "${ClassHelpers__NS__getName(this.__repository.target)}"`,
594
+ // );
595
+ // debugger;
596
+ const totalCount = await this.repo.count();
597
+ const models = await this.repo.find();
598
+ // console.log('models', models);
599
+ // console.log('totalCount', totalCount);
600
+ return { models, totalCount };
601
+ //#endregion
602
+ }
603
+ //#endregion
604
+ //#region crud operations / get by id
605
+ async getBy(id) {
606
+ //#region @websqlFunc
607
+ const model = await await this.repo.findOne({
608
+ where: { id },
609
+ });
610
+ return model;
611
+ //#endregion
76
612
  }
77
- this[this.REPOS_CACHE_KEY] = repo;
78
- return this[this.REPOS_CACHE_KEY];
79
- }
80
- /**
81
- * target for repository
82
- */
83
- get target() {
84
- return this?.repository?.target;
85
- }
86
- /**
87
- * alias to repository
88
- */
89
- get repo() {
90
- return this.repository;
91
- }
92
- get repositoryExists() {
93
- return !!this.repository;
94
- }
95
- //#endregion
96
- //#region crud operations / typeorm / has id
97
- /**
98
- * Checks if entity has an id.
99
- * If entity composite compose ids, it will check them all.
100
- */
101
- hasId(entity) {
102
- return this.repo.hasId(entity);
103
- }
104
- //#endregion
105
- //#region crud operations / typeorm / get id
106
- /**
107
- * Gets entity mixed id.
108
- */
109
- getId(entity) {
110
- return this.repo.getId(entity);
111
- }
112
- //#endregion
113
- //#region crud operations / typeorm / create & bulk create
114
- /**
115
- Saves a given entity in the database.
116
- * If entity does not exist in the database then inserts, otherwise updates.
117
- */
118
- async save(item, options) {
119
- let model = await this.repo.create(item);
120
- model = await this.repo.save(model, options);
121
- const { id } = model;
122
- model = await this.repo.findOne({
123
- where: { id }
124
- });
125
- return model;
126
- }
127
- /**
128
- * Creates a new entity instance or instances.
129
- * Can copy properties from the given object into new entities.
130
- */
131
- create(plainEntityLikeOrPlainEntityLikes) {
132
- return this.repo.create(plainEntityLikeOrPlainEntityLikes);
133
- }
134
- async bulkSave(items, options) {
135
- const models = [];
136
- for (let index = 0; index < items.length; index++) {
137
- const item = items[index];
138
- const model = await this.save(item, options);
139
- models.push(model);
140
- }
141
- return models;
142
- }
143
- /**
144
- * @deprecated use bulkSave instead
145
- */
146
- async bulkCreate(items, options) {
147
- return this.bulkSave(items, options);
148
- }
149
- //#region old typeorm version
150
- /**
151
- * Saves all given entities in the database.
152
- * If entities do not exist in the database then inserts, otherwise updates.
153
- */
154
- // save<T extends DeepPartial<Entity>>(
155
- // entities: T[],
156
- // options: SaveOptions & {
157
- // reload: false;
158
- // },
159
- // ): Promise<T[]>;
160
- // /**
161
- // * Saves all given entities in the database.
162
- // * If entities do not exist in the database then inserts, otherwise updates.
163
- // */
164
- // save<T extends DeepPartial<Entity>>(
165
- // entities: T[],
166
- // options?: SaveOptions,
167
- // ): Promise<(T & Entity)[]>;
168
- // /**
169
- // * Saves a given entity in the database.
170
- // * If entity does not exist in the database then inserts, otherwise updates.
171
- // */
172
- // save<T extends DeepPartial<Entity>>(
173
- // entity: T,
174
- // options: SaveOptions & {
175
- // reload: false;
176
- // },
177
- // ): Promise<T>;
178
- // /**
179
- // * Saves a given entity in the database.
180
- // * If entity does not exist in the database then inserts, otherwise updates.
181
- // */
182
- // save<T extends DeepPartial<Entity>>(
183
- // entity: T,
184
- // options?: SaveOptions,
185
- // ): Promise<T & Entity> {
186
- // return this.repo.save(entity, options);
187
- // }
188
- //#endregion
189
- //#endregion
190
- //#region crud operations / typeorm / merge
191
- /**
192
- * Merges multiple entities (or entity-like objects) into a given entity.
193
- */
194
- merge(mergeIntoEntity, ...entityLikes) {
195
- return this.repo.merge(mergeIntoEntity, ...entityLikes);
196
- }
197
- //#endregion
198
- //#region crud operations / typeorm / preload
199
- /**
200
- * Creates a new entity from the given plain javascript object. If entity already exist in the database, then
201
- * it loads it (and everything related to it), replaces all values with the new ones from the given object
202
- * and returns this new entity. This new entity is actually a loaded from the db entity with all properties
203
- * replaced from the new object.
204
- *
205
- * Note that given entity-like object must have an entity id / primary key to find entity by.
206
- * Returns undefined if entity with given id was not found.
207
- */
208
- preload(entityLike) {
209
- return this.repo.preload(entityLike);
210
- }
211
- //#endregion
212
- //#region crud operations / typeorm / remove (delete) & bulk remove (delete)
213
- /**
214
- * Removes a given entities from the database.
215
- */
216
- async remove(idOrEntity) {
217
- if (___NS__isObject(idOrEntity)) {
218
- idOrEntity = idOrEntity.id;
219
- }
220
- const deletedEntity = await this.repo.findOne({
221
- where: { id: idOrEntity }
222
- });
223
- if (!deletedEntity) {
224
- Helpers__NS__warn(
225
- `[TaonBaseRepository] Entity "${ClassHelpers__NS__getName(
226
- this.repo.target
227
- )}" with id ${idOrEntity} not found, cannot remove`
228
- );
229
- return;
230
- }
231
- const idCopy = deletedEntity.id;
232
- await this.repo.remove(deletedEntity);
233
- deletedEntity.id = idCopy;
234
- return deletedEntity;
235
- }
236
- /**
237
- * alias to remove
238
- */
239
- async delete(idOrEntity) {
240
- return this.remove(idOrEntity);
241
- }
242
- /**
243
- * alias to removeById
244
- */
245
- async deleteById(id) {
246
- return this.remove(id);
247
- }
248
- async bulkRemove(idsOrEntities) {
249
- idsOrEntities = idsOrEntities.map((id) => {
250
- return ___NS__isObject(id) ? id.id : id;
251
- });
252
- const models = [];
253
- for (let index = 0; index < idsOrEntities.length; index++) {
254
- const id = idsOrEntities[index];
255
- const model = await this.remove(id);
256
- models.push(model);
257
- }
258
- return models;
259
- }
260
- async bulkDelete(ids) {
261
- return this.bulkRemove(ids);
262
- }
263
- /**
264
- * Records the delete date of a given entity.
265
- */
266
- softRemove(entity, options) {
267
- return this.repo.softRemove(entity, options);
268
- }
269
- /**
270
- * Recovers a given entity in the database.
271
- */
272
- recover(entity, options) {
273
- return this.repo.recover(entity, options);
274
- }
275
- //#endregion
276
- //#region crud operations / typeorm / insert
277
- /**
278
- * Inserts a given entity into the database.
279
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
280
- * Executes fast and efficient INSERT query.
281
- * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
282
- */
283
- insert(entity) {
284
- return this.repo.insert(entity);
285
- }
286
- //#endregion
287
- //#region crud operations / typeorm / update & build update
288
- async update(item) {
289
- const { id } = item;
290
- return await this.updateById(id, item);
291
- }
292
- allowedTypesToUpdate = ["simple-json", "simple-array", "json"];
293
- async updateById(id, item) {
294
- const allowedPropsToUpdate = [];
295
- for (const key in item) {
296
- const metadataColumn = this.repo.metadata.ownColumns.find(
297
- (c) => c.propertyName === key
298
- );
299
- if (___NS__isObject(item) && item.hasOwnProperty(key) && (typeof item[key] !== "object" || this.allowedTypesToUpdate.includes(metadataColumn?.type)) && !___NS__isUndefined(metadataColumn)) {
300
- allowedPropsToUpdate.push(key);
301
- }
302
- }
303
- for (let i = 0; i < allowedPropsToUpdate.length; i++) {
304
- const key = allowedPropsToUpdate[i];
305
- if (!INDEX_KEYS_NO_FOR_UPDATE.includes(key.toLowerCase())) {
306
- const toSet = item[key];
307
- await this.repo.update(
308
- {
309
- id
310
- },
311
- {
312
- [key]: toSet
313
- }
314
- );
315
- }
316
- }
317
- let model = await this.repo.findOne({
318
- where: { id }
319
- });
320
- return model;
321
- }
322
- async bulkUpdate(items) {
323
- const models = [];
324
- for (let index = 0; index < items.length; index++) {
325
- const item = items[index];
326
- const { id } = item;
327
- const model = await this.updateById(id, item);
328
- models.push(model);
329
- }
330
- return { models };
331
- }
332
- //#region tpeorm update version
333
- // this version suck and will not return update entity
334
- // /**
335
- // * Updates entity partially. Entity can be found by a given conditions.
336
- // * Unlike save method executes a primitive operation without cascades, relations and other operations included.
337
- // * Executes fast and efficient UPDATE query.
338
- // * Does not check if entity exist in the database.
339
- // */
340
- // update(
341
- // criteria:
342
- // | string
343
- // | string[]
344
- // | number
345
- // | number[]
346
- // | Date
347
- // | Date[]
348
- // | ObjectID
349
- // | ObjectID[]
350
- // | FindOptionsWhere<Entity>,
351
- // partialEntity: QueryDeepPartialEntity<Entity>,
352
- // ): Promise<UpdateResult> {
353
- // return this.repo.update(criteria, partialEntity);
354
- // }
355
- //#endregion
356
- //#endregion
357
- //#region crud operations / typeorm / upsert
358
- /**
359
- * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
360
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
361
- * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
362
- */
363
- upsert(entityOrEntities, conflictPathsOrOptions) {
364
- return this.repo.upsert(entityOrEntities, conflictPathsOrOptions);
365
- }
366
- //#endregion
367
- //#region crud operations / typeorm / soft delete
368
- /**
369
- * Records the delete date of entities by a given criteria.
370
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
371
- * Executes fast and efficient SOFT-DELETE query.
372
- * Does not check if entity exist in the database.
373
- */
374
- softDelete(criteria) {
375
- return this.repo.softDelete(criteria);
376
- }
377
- //#endregion
378
- //#region crud operations / typeorm / restore
379
- /**
380
- * Restores entities by a given criteria.
381
- * Unlike save method executes a primitive operation without cascades, relations and other operations included.
382
- * Executes fast and efficient SOFT-DELETE query.
383
- * Does not check if entity exist in the database.
384
- */
385
- restore(criteria) {
386
- return this.repo.restore(criteria);
387
- }
388
- //#endregion
389
- //#region crud operations / typeorm / count
390
- /**
391
- * Counts entities that match given options.
392
- * Useful for pagination.
393
- */
394
- count(options) {
395
- return this.repo.count(options);
396
- }
397
- //#endregion
398
- //#region crud operations / typeorm / count by
399
- /**
400
- * Counts entities that match given conditions.
401
- * Useful for pagination.
402
- */
403
- countBy(where) {
404
- return this.repo.countBy(where);
405
- }
406
- //#endregion
407
- //#region crud operations / typeorm / find
408
- /**
409
- * Finds entities that match given find options.
410
- */
411
- find(options) {
412
- return this.repo.find(options);
413
- }
414
- //#endregion
415
- //#region crud operations / typeorm / find by
416
- /**
417
- * Finds entities that match given find options.
418
- */
419
- findBy(where) {
420
- return this.repo.findBy(where);
421
- }
422
- //#endregion
423
- //#region crud operations / typeorm / find and count
424
- // async findAndCount(options: { take: number; skip: number }) {
425
- // const { take, skip } = options;
426
- // const [result, total] = await this.repo.findAndCount({
427
- // // where: { name: Like('%' + keyword + '%') },
428
- // // order: { name: "DESC" },
429
- // take: take,
430
- // skip: skip,
431
- // });
432
- // return { result, total };
433
- // }
434
- //
435
- /**
436
- * Finds entities that match given find options.
437
- * Also counts all entities that match given conditions,
438
- * but ignores pagination settings (from and take options).
439
- */
440
- findAndCount(options) {
441
- return this.repo.findAndCount(options);
442
- }
443
- //#endregion
444
- //#region crud operations / typeorm / find and count by
445
- /**
446
- * Finds entities that match given WHERE conditions.
447
- * Also counts all entities that match given conditions,
448
- * but ignores pagination settings (from and take options).
449
- */
450
- findAndCountBy(where) {
451
- return this.repo.findAndCountBy(where);
452
- }
453
- //#endregion
454
- //#region crud operations / typeorm / find by ids
455
- /**
456
- * Finds entities with ids.
457
- * Optionally find options or conditions can be applied.
458
- *
459
- * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:
460
- *
461
- * .findBy({
462
- * id: In([1, 2, 3])
463
- * })
464
- */
465
- findByIds(ids) {
466
- return this.repo.findByIds(ids);
467
- }
468
- //#endregion
469
- //#region crud operations / typeorm / find one
470
- /**
471
- * Finds first entity by a given find options.
472
- * If entity was not found in the database - returns null.
473
- */
474
- findOne(options) {
475
- return this.repo.findOne(options);
476
- }
477
- //#endregion
478
- //#region crud operations / typeorm / find one by
479
- /**
480
- * Finds first entity that matches given where condition.
481
- * If entity was not found in the database - returns null.
482
- */
483
- findOneBy(where) {
484
- return this.repo.findOneBy(where);
485
- }
486
- //#endregion
487
- //#region crud operations / typeorm / find one or fail
488
- /**
489
- * Finds first entity that matches given id.
490
- * If entity was not found in the database - returns null.
491
- *
492
- * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:
493
- *
494
- * .findOneBy({
495
- * id: 1 // where "id" is your primary column name
496
- * })
497
- */
498
- findOneById(id) {
499
- return this.repo.findOneById(id);
500
- }
501
- //#endregion
502
- //#region crud operations / typeorm / find one or fail
503
- /**
504
- * Finds first entity by a given find options.
505
- * If entity was not found in the database - rejects with error.
506
- */
507
- findOneOrFail(options) {
508
- return this.repo.findOneOrFail(options);
509
- }
510
- //#endregion
511
- //#region crud operations / typeorm / find one by or fail
512
- /**
513
- * Finds first entity that matches given where condition.
514
- * If entity was not found in the database - rejects with error.
515
- */
516
- findOneByOrFail(where) {
517
- return this.repo.findOneByOrFail(where);
518
- }
519
- //#endregion
520
- //#region crud operations / typeorm / query
521
- /**
522
- * Executes a raw SQL query and returns a raw database results.
523
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
524
- */
525
- query(query, parameters) {
526
- return this.repo.query(query, parameters);
527
- }
528
- //#endregion
529
- //#region crud operations / typeorm / query
530
- /**
531
- * Executes a raw SQL query and returns a raw database results.
532
- * Raw query execution is supported only by relational databases (MongoDB is not supported).
533
- */
534
- createQueryBuilder(alias, queryRunner) {
535
- return this.repo.createQueryBuilder(alias, queryRunner);
536
- }
537
- //#endregion
538
- //#region crud operations / typeorm / clear
539
- /**
540
- * Clears all the data from the given table/collection (truncates/drops it).
541
- *
542
- * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.
543
- * @see https://stackoverflow.com/a/5972738/925151
544
- */
545
- clear() {
546
- return this.repo.clear();
547
- }
548
- //#endregion
549
- //#region crud operations / typeorm / increment
550
- /**
551
- * Increments some column by provided value of the entities matched given conditions.
552
- */
553
- increment(conditions, propertyPath, value) {
554
- return this.repo.increment(conditions, propertyPath, value);
555
- }
556
- //#endregion
557
- //#region crud operations / typeorm / decrement
558
- /**
559
- * Decrements some column by provided value of the entities matched given conditions.
560
- */
561
- decrement(conditions, propertyPath, value) {
562
- return this.repo.decrement(conditions, propertyPath, value);
563
- }
564
- //#endregion
565
- //#region crud operations / get all
566
- /**
567
- * @deprecated use findAndCount instead
568
- */
569
- async getAll() {
570
- const totalCount = await this.repo.count();
571
- const models = await this.repo.find();
572
- return { models, totalCount };
573
- }
574
- //#endregion
575
- //#region crud operations / get by id
576
- async getBy(id) {
577
- const model = await await this.repo.findOne({
578
- where: { id }
579
- });
580
- return model;
581
- }
582
- //#endregion
583
613
  };
584
- TaonBaseRepository = __decorateClass([
585
- TaonRepository({ className: "TaonBaseRepository" })
614
+ TaonBaseRepository = __decorate([
615
+ TaonRepository({ className: 'TaonBaseRepository' })
586
616
  ], TaonBaseRepository);
587
- export {
588
- TaonBaseRepository
589
- };
617
+ export { TaonBaseRepository };