@futdevpro/nts-dynamo 1.5.69 → 1.5.72
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.
- package/lib/_models/dynamo-nts-api-call-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-api-call-params.js +3 -1
- package/lib/_models/dynamo-nts-api-call-params.js.map +1 -1
- package/lib/_models/dynamo-nts-app-params.js +3 -2
- package/lib/_models/dynamo-nts-app-params.js.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.js +12 -8
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
- package/lib/_modules/constants.index.d.ts +2 -0
- package/lib/_modules/constants.index.d.ts.map +1 -0
- package/lib/_modules/constants.index.js +5 -0
- package/lib/_modules/constants.index.js.map +1 -0
- package/lib/_modules/custom-data-module.index.d.ts +2 -0
- package/lib/_modules/custom-data-module.index.d.ts.map +1 -0
- package/lib/_modules/custom-data-module.index.js +5 -0
- package/lib/_modules/custom-data-module.index.js.map +1 -0
- package/lib/_modules/enums.index.d.ts +2 -0
- package/lib/_modules/enums.index.d.ts.map +1 -0
- package/lib/_modules/enums.index.js +5 -0
- package/lib/_modules/enums.index.js.map +1 -0
- package/lib/_modules/models.index.d.ts +2 -0
- package/lib/_modules/models.index.d.ts.map +1 -0
- package/lib/_modules/models.index.js +5 -0
- package/lib/_modules/models.index.js.map +1 -0
- package/lib/_modules/services.index.d.ts +2 -0
- package/lib/_modules/services.index.d.ts.map +1 -0
- package/lib/_modules/services.index.js +5 -0
- package/lib/_modules/services.index.js.map +1 -0
- package/lib/_modules/test/test.controller.d.ts.map +1 -1
- package/lib/_modules/test/test.controller.js +4 -1
- package/lib/_modules/test/test.controller.js.map +1 -1
- package/lib/_modules/test-module.index.d.ts +2 -0
- package/lib/_modules/test-module.index.d.ts.map +1 -0
- package/lib/_modules/test-module.index.js +5 -0
- package/lib/_modules/test-module.index.js.map +1 -0
- package/lib/_modules/usage-module.index.d.ts +2 -0
- package/lib/_modules/usage-module.index.d.ts.map +1 -0
- package/lib/_modules/usage-module.index.js +5 -0
- package/lib/_modules/usage-module.index.js.map +1 -0
- package/lib/_services/dynamo-nts-app-extended.d.ts +5 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +6 -4
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +46 -37
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +67 -39
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +2 -0
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +38 -38
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db.service.d.ts +10 -11
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +76 -224
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +22 -14
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js +7 -0
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/_models/dynamo-nts-api-call-params.ts +5 -1
- package/src/_models/dynamo-nts-app-params.ts +2 -2
- package/src/_models/dynamo-nts-endpoint-params.ts +22 -8
- package/src/_modules/constants.index.ts +2 -0
- package/src/_modules/custom-data-module.index.ts +2 -0
- package/src/_modules/enums.index.ts +2 -0
- package/src/_modules/models.index.ts +2 -0
- package/src/_modules/services.index.ts +2 -0
- package/src/_modules/test/test.controller.ts +4 -1
- package/src/_modules/test-module.index.ts +2 -0
- package/src/_modules/usage-module.index.ts +2 -0
- package/src/_services/dynamo-nts-app-extended.ts +11 -4
- package/src/_services/dynamo-nts-app.ts +131 -76
- package/src/_services/dynamo-nts-data.service.ts +44 -38
- package/src/_services/dynamo-nts-db.service.ts +92 -229
- package/src/_services/dynamo-nts-global.service.ts +30 -18
|
@@ -6,7 +6,7 @@ import { Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_E
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
9
|
+
export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U extends T = any> {
|
|
10
10
|
dataModel = mongoose.model(this.dataParams.dbName, this.getSchema());
|
|
11
11
|
|
|
12
12
|
private depDataName: string;
|
|
@@ -32,11 +32,11 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
32
32
|
* @param data data
|
|
33
33
|
* @returns data
|
|
34
34
|
*/
|
|
35
|
-
async createData(data: T,
|
|
35
|
+
async createData(data: T, issuer: string): Promise<T> {
|
|
36
36
|
data.__created = new Date();
|
|
37
37
|
data.__lastModified = new Date();
|
|
38
|
-
data.__createdBy =
|
|
39
|
-
data.__lastModifiedBy =
|
|
38
|
+
data.__createdBy = issuer;
|
|
39
|
+
data.__lastModifiedBy = issuer;
|
|
40
40
|
|
|
41
41
|
const dataModel = new this.dataModel(data);
|
|
42
42
|
let newData: T = await dataModel.save().then(res => {
|
|
@@ -80,37 +80,22 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
80
80
|
* @param data data
|
|
81
81
|
* @returns data
|
|
82
82
|
*/
|
|
83
|
-
async modifyData(data: T,
|
|
83
|
+
async modifyData(data: T, issuer: string): Promise<T> {
|
|
84
84
|
data.__lastModified = new Date();
|
|
85
|
-
data.__lastModifiedBy =
|
|
85
|
+
data.__lastModifiedBy = issuer;
|
|
86
86
|
|
|
87
87
|
const dataModel = new this.dataModel(data);
|
|
88
88
|
let newData: T = await this.dataModel.findByIdAndUpdate(data._id, dataModel).then(res => {
|
|
89
89
|
return res?.toObject() as T ?? null;
|
|
90
|
-
/* if (res) {
|
|
91
|
-
return res?.toObject() as T;
|
|
92
|
-
} else {
|
|
93
|
-
throw new Dynamo_Error({
|
|
94
|
-
status: 204,
|
|
95
|
-
errorCode: 'NTS-DBS-FU1',
|
|
96
|
-
addECToUserMsg: true,
|
|
97
|
-
message: `update ${this.dataParams.dbName} result not found! (NTS DB)`,
|
|
98
|
-
userMessage: this.defaultErrorUserMsg
|
|
99
|
-
});
|
|
100
|
-
} */
|
|
101
90
|
}).catch(error => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
userMessage: this.defaultErrorUserMsg,
|
|
111
|
-
error
|
|
112
|
-
});
|
|
113
|
-
}
|
|
91
|
+
throw new Dynamo_Error({
|
|
92
|
+
status: 417,
|
|
93
|
+
errorCode: 'NTS-DBS-FU0',
|
|
94
|
+
addECToUserMsg: true,
|
|
95
|
+
message: `modify ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
|
|
96
|
+
userMessage: this.defaultErrorUserMsg,
|
|
97
|
+
error
|
|
98
|
+
});
|
|
114
99
|
});
|
|
115
100
|
|
|
116
101
|
if (typeof newData._id === 'object') {
|
|
@@ -124,37 +109,21 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
124
109
|
|
|
125
110
|
/**
|
|
126
111
|
* returns data by _id,
|
|
127
|
-
* !!!: throws error if not found (errorCode on not found: NTS-DBS-GI1)
|
|
128
112
|
* @param id id
|
|
129
113
|
* @returns data
|
|
130
114
|
*/
|
|
131
115
|
async getDataById(id: string): Promise<T> {
|
|
132
116
|
let data: T = await this.dataModel.findById(id).then(res => {
|
|
133
117
|
return res?.toObject() as T ?? null;
|
|
134
|
-
/* if (res) {
|
|
135
|
-
return res?.toObject() as T;
|
|
136
|
-
} else {
|
|
137
|
-
throw new Dynamo_Error({
|
|
138
|
-
status: 417,
|
|
139
|
-
errorCode: 'NTS-DBS-GI1',
|
|
140
|
-
addECToUserMsg: true,
|
|
141
|
-
message: `get ${this.dataParams.dbName} by ID was unsuccessful: data not found by id: ${id} (NTS DB)`,
|
|
142
|
-
userMessage: this.defaultErrorUserMsg
|
|
143
|
-
});
|
|
144
|
-
} */
|
|
145
118
|
}).catch(error => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
userMessage: this.defaultErrorUserMsg,
|
|
155
|
-
error
|
|
156
|
-
});
|
|
157
|
-
}
|
|
119
|
+
throw new Dynamo_Error({
|
|
120
|
+
status: 417,
|
|
121
|
+
errorCode: 'NTS-DBS-GI0',
|
|
122
|
+
addECToUserMsg: true,
|
|
123
|
+
message: `get ${this.dataParams.dbName} by ID was unsuccessful (NTS DB)`,
|
|
124
|
+
userMessage: this.defaultErrorUserMsg,
|
|
125
|
+
error
|
|
126
|
+
});
|
|
158
127
|
});
|
|
159
128
|
|
|
160
129
|
if (data && typeof data._id === 'object') {
|
|
@@ -184,30 +153,15 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
184
153
|
|
|
185
154
|
let data: T = await this.dataModel.findOne({ [this.depDataName]: dependencyId }).then(res => {
|
|
186
155
|
return res?.toObject() as T ?? null;
|
|
187
|
-
/* if (res) {
|
|
188
|
-
return res?.toObject() as T;
|
|
189
|
-
} else {
|
|
190
|
-
throw new Dynamo_Error({
|
|
191
|
-
status: 417,
|
|
192
|
-
errorCode: 'NTS-DBS-GD2',
|
|
193
|
-
addECToUserMsg: true,
|
|
194
|
-
message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful: data not found by id: ${dependencyId} (NTS DB)`,
|
|
195
|
-
userMessage: this.defaultErrorUserMsg
|
|
196
|
-
});
|
|
197
|
-
} */
|
|
198
156
|
}).catch(error => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
userMessage: this.defaultErrorUserMsg,
|
|
208
|
-
error
|
|
209
|
-
});
|
|
210
|
-
}
|
|
157
|
+
throw new Dynamo_Error({
|
|
158
|
+
status: 417,
|
|
159
|
+
errorCode: 'NTS-DBS-GD1',
|
|
160
|
+
addECToUserMsg: true,
|
|
161
|
+
message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
|
|
162
|
+
userMessage: this.defaultErrorUserMsg,
|
|
163
|
+
error
|
|
164
|
+
});
|
|
211
165
|
});
|
|
212
166
|
|
|
213
167
|
if (data && typeof data._id === 'object') {
|
|
@@ -237,30 +191,15 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
237
191
|
|
|
238
192
|
let dataList: T[] = await this.dataModel.find({ [this.depDataName]: dependencyId }).then(res => {
|
|
239
193
|
return res as T[] ?? [];
|
|
240
|
-
/* if (res) {
|
|
241
|
-
return res as T[];
|
|
242
|
-
} else {
|
|
243
|
-
throw new Dynamo_Error({
|
|
244
|
-
status: 417,
|
|
245
|
-
errorCode: 'NTS-DBS-GLD2',
|
|
246
|
-
addECToUserMsg: true,
|
|
247
|
-
message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful: no data found by id: ${dependencyId} (NTS DB)`,
|
|
248
|
-
userMessage: this.defaultErrorUserMsg
|
|
249
|
-
});
|
|
250
|
-
} */
|
|
251
194
|
}).catch(error => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
userMessage: this.defaultErrorUserMsg,
|
|
261
|
-
error
|
|
262
|
-
});
|
|
263
|
-
}
|
|
195
|
+
throw new Dynamo_Error({
|
|
196
|
+
status: 417,
|
|
197
|
+
errorCode: 'NTS-DBS-GLD1',
|
|
198
|
+
addECToUserMsg: true,
|
|
199
|
+
message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
|
|
200
|
+
userMessage: this.defaultErrorUserMsg,
|
|
201
|
+
error
|
|
202
|
+
});
|
|
264
203
|
});
|
|
265
204
|
|
|
266
205
|
if (0 < dataList.length) {
|
|
@@ -294,30 +233,15 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
294
233
|
|
|
295
234
|
let dataList: T[] = await this.dataModel.find({ [this.depDataName]: { $in: ids }}).then(res => {
|
|
296
235
|
return res as T[] ?? [];
|
|
297
|
-
/* if (res) {
|
|
298
|
-
return res as T[];
|
|
299
|
-
} else {
|
|
300
|
-
throw new Dynamo_Error({
|
|
301
|
-
status: 417,
|
|
302
|
-
errorCode: 'NTS-DBS-GLDS2',
|
|
303
|
-
addECToUserMsg: true,
|
|
304
|
-
message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful: no data found by ids: ${ids} (NTS DB)`,
|
|
305
|
-
userMessage: this.defaultErrorUserMsg
|
|
306
|
-
});
|
|
307
|
-
} */
|
|
308
236
|
}).catch(error => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
userMessage: this.defaultErrorUserMsg,
|
|
318
|
-
error
|
|
319
|
-
});
|
|
320
|
-
}
|
|
237
|
+
throw new Dynamo_Error({
|
|
238
|
+
status: 417,
|
|
239
|
+
errorCode: 'NTS-DBS-GLDS1',
|
|
240
|
+
addECToUserMsg: true,
|
|
241
|
+
message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (NTS DB)`,
|
|
242
|
+
userMessage: this.defaultErrorUserMsg,
|
|
243
|
+
error
|
|
244
|
+
});
|
|
321
245
|
});
|
|
322
246
|
|
|
323
247
|
if (0 < dataList.length) {
|
|
@@ -339,7 +263,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
339
263
|
* @param narrowByDependencyIds id
|
|
340
264
|
* @returns dataList
|
|
341
265
|
*/
|
|
342
|
-
async searchData(searchBy:
|
|
266
|
+
async searchData(searchBy: F, narrowByDependencyIds?: string[]): Promise<T[]> {
|
|
343
267
|
const filter = {};
|
|
344
268
|
|
|
345
269
|
if (0 < narrowByDependencyIds.length) {
|
|
@@ -437,30 +361,15 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
437
361
|
let dataList: T[] = await this.dataModel.find({})
|
|
438
362
|
.then(res => {
|
|
439
363
|
return res as T[] ?? [];
|
|
440
|
-
/* if (res) {
|
|
441
|
-
return res as T[];
|
|
442
|
-
} else {
|
|
443
|
-
throw new Dynamo_Error({
|
|
444
|
-
status: 417,
|
|
445
|
-
errorCode: 'NTS-DBS-GA1',
|
|
446
|
-
addECToUserMsg: true,
|
|
447
|
-
message: `get all ${this.dataParams.dbName} was unsuccessful: no data found (NTS DB)`,
|
|
448
|
-
userMessage: this.defaultErrorUserMsg
|
|
449
|
-
});
|
|
450
|
-
} */
|
|
451
364
|
}).catch(error => {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
userMessage: this.defaultErrorUserMsg,
|
|
461
|
-
error
|
|
462
|
-
});
|
|
463
|
-
}
|
|
365
|
+
throw new Dynamo_Error({
|
|
366
|
+
status: 417,
|
|
367
|
+
errorCode: 'NTS-DBS-GA0',
|
|
368
|
+
addECToUserMsg: true,
|
|
369
|
+
message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
|
|
370
|
+
userMessage: this.defaultErrorUserMsg,
|
|
371
|
+
error
|
|
372
|
+
});
|
|
464
373
|
});
|
|
465
374
|
|
|
466
375
|
if (0 < dataList.length && typeof dataList[0]._id === 'object') {
|
|
@@ -547,34 +456,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
547
456
|
* //
|
|
548
457
|
* @returns {T} data: T
|
|
549
458
|
*/
|
|
550
|
-
async findOne(filter:
|
|
459
|
+
async findOne(filter: F): Promise<T> {
|
|
551
460
|
let data: T = await this.dataModel.findOne(filter).then(res => {
|
|
552
461
|
return res as T ?? null;
|
|
553
|
-
/* if (res) {
|
|
554
|
-
return res as T;
|
|
555
|
-
} else {
|
|
556
|
-
return null;
|
|
557
|
-
throw new Dynamo_Error({
|
|
558
|
-
status: 417,
|
|
559
|
-
errorCode: 'NTS-DBS-FO1',
|
|
560
|
-
addECToUserMsg: true,
|
|
561
|
-
message: `findOne ${this.dataParams.dbName} was unsuccessful, no data found (NTS DB) fliter: ${filter}`,
|
|
562
|
-
userMessage: this.defaultErrorUserMsg
|
|
563
|
-
});
|
|
564
|
-
} */
|
|
565
462
|
}).catch(error => {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
userMessage: this.defaultErrorUserMsg,
|
|
575
|
-
error
|
|
576
|
-
});
|
|
577
|
-
}
|
|
463
|
+
throw new Dynamo_Error({
|
|
464
|
+
status: 417,
|
|
465
|
+
errorCode: 'NTS-DBS-FO0',
|
|
466
|
+
addECToUserMsg: true,
|
|
467
|
+
message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB) fliter: ${filter}`,
|
|
468
|
+
userMessage: this.defaultErrorUserMsg,
|
|
469
|
+
error
|
|
470
|
+
});
|
|
578
471
|
});
|
|
579
472
|
|
|
580
473
|
if (data && typeof data._id === 'object') {
|
|
@@ -611,34 +504,19 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
611
504
|
* //
|
|
612
505
|
* @returns {T[]} dataList: T[]
|
|
613
506
|
*/
|
|
614
|
-
async find(filter:
|
|
507
|
+
async find(filter: F): Promise<T[]> {
|
|
615
508
|
let dataList: T[] = await this.dataModel.find(filter)
|
|
616
509
|
.then(res => {
|
|
617
510
|
return res as T[] ?? [];
|
|
618
|
-
/* if (res) {
|
|
619
|
-
return res as T[];
|
|
620
|
-
} else {
|
|
621
|
-
throw new Dynamo_Error({
|
|
622
|
-
status: 417,
|
|
623
|
-
errorCode: 'NTS-DBS-F1',
|
|
624
|
-
addECToUserMsg: true,
|
|
625
|
-
message: `find ${this.dataParams.dbName} was unsuccessful, no data found (NTS DB) fliter: ${filter}`,
|
|
626
|
-
userMessage: this.defaultErrorUserMsg
|
|
627
|
-
});
|
|
628
|
-
} */
|
|
629
511
|
}).catch(error => {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
userMessage: this.defaultErrorUserMsg,
|
|
639
|
-
error
|
|
640
|
-
});
|
|
641
|
-
}
|
|
512
|
+
throw new Dynamo_Error({
|
|
513
|
+
status: 417,
|
|
514
|
+
errorCode: 'NTS-DBS-F0',
|
|
515
|
+
addECToUserMsg: true,
|
|
516
|
+
message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
|
|
517
|
+
userMessage: this.defaultErrorUserMsg,
|
|
518
|
+
error
|
|
519
|
+
});
|
|
642
520
|
});
|
|
643
521
|
|
|
644
522
|
if (0 < dataList.length) {
|
|
@@ -685,7 +563,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
685
563
|
* //
|
|
686
564
|
* @returns {T[]} dataList: T[]
|
|
687
565
|
*/
|
|
688
|
-
async findWithPaging(filter:
|
|
566
|
+
async findWithPaging(filter: F, page: number, pageSize: number, sort?: any): Promise<T[]> {
|
|
689
567
|
let dataList: T[] = await this.dataModel.find(filter)
|
|
690
568
|
.sort(sort)
|
|
691
569
|
.skip(page * pageSize)
|
|
@@ -722,36 +600,21 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
722
600
|
* @param update update
|
|
723
601
|
* @returns data
|
|
724
602
|
*/
|
|
725
|
-
async findByIdAndUpdate(id: string, update:
|
|
603
|
+
async findByIdAndUpdate(id: string, update: U, modifier: string): Promise<T> {
|
|
726
604
|
update.__lastModified = new Date();
|
|
727
605
|
update.__lastModifiedBy = modifier;
|
|
728
606
|
|
|
729
607
|
let newData: T = await this.dataModel.findByIdAndUpdate(id, update).then(res => {
|
|
730
608
|
return res?.toObject() as T ?? null;
|
|
731
|
-
/* if (res) {
|
|
732
|
-
return res?.toObject() as T;
|
|
733
|
-
} else {
|
|
734
|
-
throw new Dynamo_Error({
|
|
735
|
-
status: 204,
|
|
736
|
-
errorCode: 'NTS-DBS-FIU1',
|
|
737
|
-
addECToUserMsg: true,
|
|
738
|
-
message: `${this.dataParams.dbName} not found! (by id: ${id}) (NTS DB)`,
|
|
739
|
-
userMessage: this.defaultErrorUserMsg
|
|
740
|
-
});
|
|
741
|
-
} */
|
|
742
609
|
}).catch(error => {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
userMessage: this.defaultErrorUserMsg,
|
|
752
|
-
error
|
|
753
|
-
});
|
|
754
|
-
}
|
|
610
|
+
throw new Dynamo_Error({
|
|
611
|
+
status: 417,
|
|
612
|
+
errorCode: 'NTS-DBS-FIU0',
|
|
613
|
+
addECToUserMsg: true,
|
|
614
|
+
message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
|
|
615
|
+
userMessage: this.defaultErrorUserMsg,
|
|
616
|
+
error
|
|
617
|
+
});
|
|
755
618
|
});
|
|
756
619
|
|
|
757
620
|
if (typeof newData._id === 'object') {
|
|
@@ -813,12 +676,11 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
813
676
|
* $unset: // Removes the specified field from a document. (set: "" to value)
|
|
814
677
|
* //
|
|
815
678
|
*/
|
|
816
|
-
async updateOne(updateBy:
|
|
679
|
+
async updateOne(updateBy: F, update: U, issuer: string): Promise<void> {
|
|
817
680
|
update.__lastModified = new Date();
|
|
818
|
-
update.__lastModifiedBy =
|
|
681
|
+
update.__lastModifiedBy = issuer;
|
|
819
682
|
|
|
820
|
-
await this.dataModel.updateOne(updateBy, update)
|
|
821
|
-
.catch(error => {
|
|
683
|
+
await this.dataModel.updateOne(updateBy, update).catch(error => {
|
|
822
684
|
throw new Dynamo_Error({
|
|
823
685
|
status: 417,
|
|
824
686
|
errorCode: 'NTS-DBS-UO0',
|
|
@@ -881,12 +743,11 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
881
743
|
* $unset: // Removes the specified field from a document. (set: "" to value)
|
|
882
744
|
* //
|
|
883
745
|
*/
|
|
884
|
-
async updateMany(updateBy:
|
|
746
|
+
async updateMany(updateBy: F, update: U, issuer: string): Promise<void> {
|
|
885
747
|
update.__lastModified = new Date();
|
|
886
|
-
update.__lastModifiedBy =
|
|
748
|
+
update.__lastModifiedBy = issuer;
|
|
887
749
|
|
|
888
|
-
await this.dataModel.updateMany(updateBy, update)
|
|
889
|
-
.catch(error => {
|
|
750
|
+
await this.dataModel.updateMany(updateBy, update).catch(error => {
|
|
890
751
|
throw new Dynamo_Error({
|
|
891
752
|
status: 417,
|
|
892
753
|
errorCode: 'NTS-DBS-UM0',
|
|
@@ -1003,7 +864,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
1003
864
|
*/
|
|
1004
865
|
private lookForDependencyDataSettings(): void {
|
|
1005
866
|
const dependencyParam: Dynamo_DataPropertyParams = this.dataParams.modelParams.find(
|
|
1006
|
-
|
|
867
|
+
(modelParams: Dynamo_DataPropertyParams) => modelParams.isDependencyHook
|
|
868
|
+
);
|
|
869
|
+
|
|
1007
870
|
if (dependencyParam) {
|
|
1008
871
|
this.depDataName = dependencyParam.key;
|
|
1009
872
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { Dynamo_Metadata, Dynamo_DataParams, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
4
|
+
import { DynamoNTS_AppParams } from '../_models';
|
|
4
5
|
|
|
5
6
|
import { DynamoNTS_AuthService } from './dynamo-nts-auth.service';
|
|
6
7
|
import { DynamoNTS_DBServiceCollection } from './dynamo-nts-db-service-collection.service';
|
|
@@ -10,6 +11,23 @@ import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
|
10
11
|
import { DynamoNTS_SocketServiceCollection } from './dynamo-nts-socket-service-collection.service';
|
|
11
12
|
import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
|
|
12
13
|
|
|
14
|
+
export interface DynamoNTS_GlobalServiceSettings {
|
|
15
|
+
/**
|
|
16
|
+
* You need to setup your Own Auth Service extending the DynamoBEAuthService class
|
|
17
|
+
*/
|
|
18
|
+
authService?: DynamoNTS_AuthService,
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* You can setup your Own Email Service extending the DynamoBEEmailServiceCollection class
|
|
22
|
+
*/
|
|
23
|
+
emailServiceCollection?: DynamoNTS_EmailServiceCollection,
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* you can setup data tables by passing a DynamoBEDataParams list at this point
|
|
27
|
+
*/
|
|
28
|
+
dbModels: Dynamo_DataParams[],
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
/**
|
|
14
32
|
* This is the main Global/Core Service Collection used by DynamoBE,
|
|
15
33
|
* you also can use this to access main services as
|
|
@@ -21,6 +39,13 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
21
39
|
return DynamoNTS_GlobalService.getSingletonInstance();
|
|
22
40
|
}
|
|
23
41
|
|
|
42
|
+
private static _params: DynamoNTS_AppParams;
|
|
43
|
+
static get params(): DynamoNTS_AppParams { return this._params; }
|
|
44
|
+
|
|
45
|
+
private static readonly _upSince: Date = new Date();
|
|
46
|
+
static get upSince(): Date { return this._upSince; }
|
|
47
|
+
static get upTime(): number { return +new Date() - +this._upSince; }
|
|
48
|
+
|
|
24
49
|
authService: DynamoNTS_AuthService;
|
|
25
50
|
dbServiceCollection: DynamoNTS_DBServiceCollection;
|
|
26
51
|
emailServiceCollection: DynamoNTS_EmailServiceCollection;
|
|
@@ -30,24 +55,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
30
55
|
/**
|
|
31
56
|
* You need to setup global Services through this function
|
|
32
57
|
*/
|
|
33
|
-
static setServices(
|
|
34
|
-
set: {
|
|
35
|
-
/**
|
|
36
|
-
* You need to setup your Own Auth Service extending the DynamoBEAuthService class
|
|
37
|
-
*/
|
|
38
|
-
authService?: DynamoNTS_AuthService,
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* You can setup your Own Email Service extending the DynamoBEEmailServiceCollection class
|
|
42
|
-
*/
|
|
43
|
-
emailServiceCollection?: DynamoNTS_EmailServiceCollection,
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* you can setup data tables by passing a DynamoBEDataParams list at this point
|
|
47
|
-
*/
|
|
48
|
-
dbModels: Dynamo_DataParams[],
|
|
49
|
-
}
|
|
50
|
-
): void {
|
|
58
|
+
static setServices(set: DynamoNTS_GlobalServiceSettings): void {
|
|
51
59
|
this.getInstance();
|
|
52
60
|
|
|
53
61
|
try {
|
|
@@ -67,6 +75,10 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
static setParams(params: DynamoNTS_AppParams): void {
|
|
79
|
+
this._params = params;
|
|
80
|
+
}
|
|
81
|
+
|
|
70
82
|
/**
|
|
71
83
|
*
|
|
72
84
|
* @returns
|