@futdevpro/nts-dynamo 1.5.50 → 1.5.52

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 (167) hide show
  1. package/lib/_models/dynamo-nts-endpoint-params.js +3 -2
  2. package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
  3. package/lib/_services/dynamo-nts-api.service.d.ts +1 -0
  4. package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
  5. package/lib/_services/dynamo-nts-api.service.js +6 -5
  6. package/lib/_services/dynamo-nts-api.service.js.map +1 -1
  7. package/lib/_services/dynamo-nts-app-extended.d.ts +87 -7
  8. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
  9. package/lib/_services/dynamo-nts-app-extended.js +87 -7
  10. package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
  11. package/lib/_services/dynamo-nts-app.d.ts +131 -22
  12. package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
  13. package/lib/_services/dynamo-nts-app.js +104 -1
  14. package/lib/_services/dynamo-nts-app.js.map +1 -1
  15. package/lib/_services/dynamo-nts-auth.service.d.ts +79 -5
  16. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
  17. package/lib/_services/dynamo-nts-auth.service.js +3 -2
  18. package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
  19. package/lib/_services/dynamo-nts-data.service.d.ts +25 -1
  20. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  21. package/lib/_services/dynamo-nts-data.service.js +98 -70
  22. package/lib/_services/dynamo-nts-data.service.js.map +1 -1
  23. package/lib/_services/dynamo-nts-db.service.d.ts +165 -119
  24. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
  25. package/lib/_services/dynamo-nts-db.service.js +348 -293
  26. package/lib/_services/dynamo-nts-db.service.js.map +1 -1
  27. package/lib/_services/dynamo-nts-email.service.d.ts +1 -0
  28. package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
  29. package/lib/_services/dynamo-nts-email.service.js +5 -4
  30. package/lib/_services/dynamo-nts-email.service.js.map +1 -1
  31. package/lib/_services/dynamo-nts-routing-module.service.d.ts +40 -0
  32. package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
  33. package/lib/_services/dynamo-nts-routing-module.service.js +43 -3
  34. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
  35. package/lib/_services/dynamo-nts-socket.service.d.ts +1 -0
  36. package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
  37. package/lib/_services/dynamo-nts-socket.service.js +6 -2
  38. package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
  39. package/lib/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +16 -12
  41. package/src/_models/dynamo-nts-endpoint-params.ts +2 -2
  42. package/src/_services/dynamo-nts-api.service.ts +7 -5
  43. package/src/_services/dynamo-nts-app-extended.ts +87 -7
  44. package/src/_services/dynamo-nts-app.ts +131 -22
  45. package/src/_services/dynamo-nts-auth.service.ts +83 -7
  46. package/src/_services/dynamo-nts-data.service.ts +100 -71
  47. package/src/_services/dynamo-nts-db.service.ts +377 -297
  48. package/src/_services/dynamo-nts-email.service.ts +6 -4
  49. package/src/_services/dynamo-nts-routing-module.service.ts +44 -3
  50. package/src/_services/dynamo-nts-socket.service.ts +13 -7
  51. package/futdevpro-nts-dynamo-01.05.40.tgz +0 -0
  52. package/futdevpro-nts-dynamo-01.05.41.tgz +0 -0
  53. package/futdevpro-nts-dynamo-01.05.42.tgz +0 -0
  54. package/futdevpro-nts-dynamo-01.05.43.tgz +0 -0
  55. package/futdevpro-nts-dynamo-01.05.44.tgz +0 -0
  56. package/futdevpro-nts-dynamo-01.05.45.tgz +0 -0
  57. package/futdevpro-nts-dynamo-01.05.47.tgz +0 -0
  58. package/futdevpro-nts-dynamo-01.05.49.tgz +0 -0
  59. package/futdevpro-nts-dynamo-01.05.50.tgz +0 -0
  60. package/lib/_constants/dynamo-nts-global.settings.d.ts +0 -3
  61. package/lib/_constants/dynamo-nts-global.settings.d.ts.map +0 -1
  62. package/lib/_constants/dynamo-nts-global.settings.js +0 -18
  63. package/lib/_constants/dynamo-nts-global.settings.js.map +0 -1
  64. package/lib/_constants/dynamobe-global.settings.d.ts +0 -3
  65. package/lib/_constants/dynamobe-global.settings.d.ts.map +0 -1
  66. package/lib/_constants/dynamobe-global.settings.js +0 -13
  67. package/lib/_constants/dynamobe-global.settings.js.map +0 -1
  68. package/lib/_enums/dynamobe-data-service-function.enum.d.ts +0 -8
  69. package/lib/_enums/dynamobe-data-service-function.enum.d.ts.map +0 -1
  70. package/lib/_enums/dynamobe-data-service-function.enum.js +0 -15
  71. package/lib/_enums/dynamobe-data-service-function.enum.js.map +0 -1
  72. package/lib/_enums/dynamobe-route-security.enum.d.ts +0 -6
  73. package/lib/_enums/dynamobe-route-security.enum.d.ts.map +0 -1
  74. package/lib/_enums/dynamobe-route-security.enum.js +0 -10
  75. package/lib/_enums/dynamobe-route-security.enum.js.map +0 -1
  76. package/lib/_enums/log-style.enum.d.ts +0 -26
  77. package/lib/_enums/log-style.enum.d.ts.map +0 -1
  78. package/lib/_enums/log-style.enum.js +0 -30
  79. package/lib/_enums/log-style.enum.js.map +0 -1
  80. package/lib/_models/dynamo-module-settings.d.ts +0 -4
  81. package/lib/_models/dynamo-module-settings.d.ts.map +0 -1
  82. package/lib/_models/dynamo-module-settings.js +0 -10
  83. package/lib/_models/dynamo-module-settings.js.map +0 -1
  84. package/lib/_models/dynamo-nts-socket-module-settings.d.ts +0 -19
  85. package/lib/_models/dynamo-nts-socket-module-settings.d.ts.map +0 -1
  86. package/lib/_models/dynamo-nts-socket-module-settings.js +0 -27
  87. package/lib/_models/dynamo-nts-socket-module-settings.js.map +0 -1
  88. package/lib/_models/dynamobe-api-call-params.d.ts +0 -37
  89. package/lib/_models/dynamobe-api-call-params.d.ts.map +0 -1
  90. package/lib/_models/dynamobe-api-call-params.js +0 -29
  91. package/lib/_models/dynamobe-api-call-params.js.map +0 -1
  92. package/lib/_models/dynamobe-app-params.d.ts +0 -18
  93. package/lib/_models/dynamobe-app-params.d.ts.map +0 -1
  94. package/lib/_models/dynamobe-app-params.js +0 -17
  95. package/lib/_models/dynamobe-app-params.js.map +0 -1
  96. package/lib/_models/dynamobe-data-model-params.d.ts +0 -1
  97. package/lib/_models/dynamobe-data-model-params.d.ts.map +0 -1
  98. package/lib/_models/dynamobe-data-model-params.js +0 -25
  99. package/lib/_models/dynamobe-data-model-params.js.map +0 -1
  100. package/lib/_models/dynamobe-endpoint-params.d.ts +0 -46
  101. package/lib/_models/dynamobe-endpoint-params.d.ts.map +0 -1
  102. package/lib/_models/dynamobe-endpoint-params.js +0 -117
  103. package/lib/_models/dynamobe-endpoint-params.js.map +0 -1
  104. package/lib/_models/dynamobe-global-settings.d.ts +0 -13
  105. package/lib/_models/dynamobe-global-settings.d.ts.map +0 -1
  106. package/lib/_models/dynamobe-global-settings.js +0 -3
  107. package/lib/_models/dynamobe-global-settings.js.map +0 -1
  108. package/lib/_modules/data-models.index.d.ts +0 -3
  109. package/lib/_modules/data-models.index.d.ts.map +0 -1
  110. package/lib/_modules/data-models.index.js +0 -6
  111. package/lib/_modules/data-models.index.js.map +0 -1
  112. package/lib/_services/dynamobe-api.service.d.ts +0 -19
  113. package/lib/_services/dynamobe-api.service.d.ts.map +0 -1
  114. package/lib/_services/dynamobe-api.service.js +0 -167
  115. package/lib/_services/dynamobe-api.service.js.map +0 -1
  116. package/lib/_services/dynamobe-app.d.ts +0 -129
  117. package/lib/_services/dynamobe-app.d.ts.map +0 -1
  118. package/lib/_services/dynamobe-app.js +0 -238
  119. package/lib/_services/dynamobe-app.js.map +0 -1
  120. package/lib/_services/dynamobe-auth.service.d.ts +0 -54
  121. package/lib/_services/dynamobe-auth.service.d.ts.map +0 -1
  122. package/lib/_services/dynamobe-auth.service.js +0 -46
  123. package/lib/_services/dynamobe-auth.service.js.map +0 -1
  124. package/lib/_services/dynamobe-controller.service.d.ts +0 -14
  125. package/lib/_services/dynamobe-controller.service.d.ts.map +0 -1
  126. package/lib/_services/dynamobe-controller.service.js +0 -21
  127. package/lib/_services/dynamobe-controller.service.js.map +0 -1
  128. package/lib/_services/dynamobe-data.service.d.ts +0 -54
  129. package/lib/_services/dynamobe-data.service.d.ts.map +0 -1
  130. package/lib/_services/dynamobe-data.service.js +0 -301
  131. package/lib/_services/dynamobe-data.service.js.map +0 -1
  132. package/lib/_services/dynamobe-db-service-collection.service.d.ts +0 -9
  133. package/lib/_services/dynamobe-db-service-collection.service.d.ts.map +0 -1
  134. package/lib/_services/dynamobe-db-service-collection.service.js +0 -11
  135. package/lib/_services/dynamobe-db-service-collection.service.js.map +0 -1
  136. package/lib/_services/dynamobe-db.service.d.ts +0 -244
  137. package/lib/_services/dynamobe-db.service.d.ts.map +0 -1
  138. package/lib/_services/dynamobe-db.service.js +0 -759
  139. package/lib/_services/dynamobe-db.service.js.map +0 -1
  140. package/lib/_services/dynamobe-email-service-collection.service.d.ts +0 -19
  141. package/lib/_services/dynamobe-email-service-collection.service.d.ts.map +0 -1
  142. package/lib/_services/dynamobe-email-service-collection.service.js +0 -21
  143. package/lib/_services/dynamobe-email-service-collection.service.js.map +0 -1
  144. package/lib/_services/dynamobe-email.service.d.ts +0 -56
  145. package/lib/_services/dynamobe-email.service.d.ts.map +0 -1
  146. package/lib/_services/dynamobe-email.service.js +0 -194
  147. package/lib/_services/dynamobe-email.service.js.map +0 -1
  148. package/lib/_services/dynamobe-global.service.d.ts +0 -62
  149. package/lib/_services/dynamobe-global.service.d.ts.map +0 -1
  150. package/lib/_services/dynamobe-global.service.js +0 -107
  151. package/lib/_services/dynamobe-global.service.js.map +0 -1
  152. package/lib/_services/dynamobe-routing-module.service.d.ts +0 -42
  153. package/lib/_services/dynamobe-routing-module.service.d.ts.map +0 -1
  154. package/lib/_services/dynamobe-routing-module.service.js +0 -146
  155. package/lib/_services/dynamobe-routing-module.service.js.map +0 -1
  156. package/lib/_services/dynamobe-shared-be.service.d.ts +0 -8
  157. package/lib/_services/dynamobe-shared-be.service.d.ts.map +0 -1
  158. package/lib/_services/dynamobe-shared-be.service.js +0 -45
  159. package/lib/_services/dynamobe-shared-be.service.js.map +0 -1
  160. package/lib/_services/dynamobe-shared.service.d.ts +0 -26
  161. package/lib/_services/dynamobe-shared.service.d.ts.map +0 -1
  162. package/lib/_services/dynamobe-shared.service.js +0 -63
  163. package/lib/_services/dynamobe-shared.service.js.map +0 -1
  164. package/lib/_services/dynamobe-singleton.service.d.ts +0 -9
  165. package/lib/_services/dynamobe-singleton.service.d.ts.map +0 -1
  166. package/lib/_services/dynamobe-singleton.service.js +0 -19
  167. package/lib/_services/dynamobe-singleton.service.js.map +0 -1
@@ -18,6 +18,7 @@ class DynamoNTS_DBService {
18
18
  constructor(dataParams) {
19
19
  this.dataParams = dataParams;
20
20
  this.dataModel = mongoose.model(this.dataParams.dbName, this.getSchema());
21
+ this.defaultErrorUserMsg = 'We encountered an unhandled DB Error, please contact the responsible development team.';
21
22
  this.lookForDependencyDataSettings();
22
23
  }
23
24
  /**
@@ -32,10 +33,9 @@ class DynamoNTS_DBService {
32
33
  data.__createdBy = creator;
33
34
  data.__lastModifiedBy = creator;
34
35
  const dataModel = new this.dataModel(data);
35
- let newData;
36
- yield dataModel.save().then(res => {
36
+ let newData = yield dataModel.save().then(res => {
37
37
  if (res) {
38
- newData = res.toObject();
38
+ return res.toObject();
39
39
  }
40
40
  else {
41
41
  throw new fsm_dynamo_1.Dynamo_Error({
@@ -43,7 +43,7 @@ class DynamoNTS_DBService {
43
43
  errorCode: 'NTS-DBS-CD1',
44
44
  addECToUserMsg: true,
45
45
  message: `save ${this.dataParams.dbName} result not found! (NTS DB)`,
46
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
46
+ userMessage: this.defaultErrorUserMsg
47
47
  });
48
48
  }
49
49
  }).catch(error => {
@@ -52,7 +52,7 @@ class DynamoNTS_DBService {
52
52
  errorCode: 'NTS-DBS-CD0',
53
53
  addECToUserMsg: true,
54
54
  message: `Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
55
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
55
+ userMessage: this.defaultErrorUserMsg,
56
56
  error
57
57
  });
58
58
  });
@@ -74,10 +74,9 @@ class DynamoNTS_DBService {
74
74
  data.__lastModified = new Date();
75
75
  data.__lastModifiedBy = modifier;
76
76
  const dataModel = new this.dataModel(data);
77
- let newData;
78
- yield this.dataModel.findByIdAndUpdate(data._id, dataModel).then(res => {
77
+ let newData = yield this.dataModel.findByIdAndUpdate(data._id, dataModel).then(res => {
79
78
  if (res) {
80
- newData = res.toObject();
79
+ return res.toObject();
81
80
  }
82
81
  else {
83
82
  throw new fsm_dynamo_1.Dynamo_Error({
@@ -85,7 +84,7 @@ class DynamoNTS_DBService {
85
84
  errorCode: 'NTS-DBS-FU1',
86
85
  addECToUserMsg: true,
87
86
  message: `update ${this.dataParams.dbName} result not found! (NTS DB)`,
88
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
87
+ userMessage: this.defaultErrorUserMsg
89
88
  });
90
89
  }
91
90
  }).catch(error => {
@@ -94,10 +93,14 @@ class DynamoNTS_DBService {
94
93
  errorCode: 'NTS-DBS-FU0',
95
94
  addECToUserMsg: true,
96
95
  message: `modify ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
97
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
96
+ userMessage: this.defaultErrorUserMsg,
98
97
  error
99
98
  });
100
99
  });
100
+ if (typeof newData._id === 'object') {
101
+ newData._id = `${newData._id}`;
102
+ }
103
+ data._id = newData._id;
101
104
  data.__v = newData.__v;
102
105
  return data;
103
106
  });
@@ -109,13 +112,12 @@ class DynamoNTS_DBService {
109
112
  */
110
113
  getDataById(id) {
111
114
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
112
- let data;
113
- yield this.dataModel.findById(id).then(res => {
115
+ let data = yield this.dataModel.findById(id).then(res => {
114
116
  if (res) {
115
- data = res.toObject();
117
+ return res.toObject();
116
118
  }
117
119
  else {
118
- data = null;
120
+ return null;
119
121
  }
120
122
  }).catch(error => {
121
123
  throw new fsm_dynamo_1.Dynamo_Error({
@@ -123,7 +125,7 @@ class DynamoNTS_DBService {
123
125
  errorCode: 'NTS-DBS-GI0',
124
126
  addECToUserMsg: true,
125
127
  message: `get ${this.dataParams.dbName} by ID was unsuccessful (NTS DB)`,
126
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
128
+ userMessage: this.defaultErrorUserMsg,
127
129
  error
128
130
  });
129
131
  });
@@ -140,39 +142,36 @@ class DynamoNTS_DBService {
140
142
  */
141
143
  getDataByDependencyId(dependencyId) {
142
144
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
143
- if (this.depDataName) {
144
- let data;
145
- yield this.dataModel.findOne({ [this.depDataName]: dependencyId }).then(res => {
146
- if (res) {
147
- data = res.toObject();
148
- }
149
- else {
150
- data = null;
151
- }
152
- }).catch(error => {
153
- throw new fsm_dynamo_1.Dynamo_Error({
154
- status: 417,
155
- errorCode: 'NTS-DBS-GD1',
156
- addECToUserMsg: true,
157
- message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
158
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
159
- error
160
- });
161
- });
162
- if (data && typeof data._id === 'object') {
163
- data._id = `${data._id}`;
164
- }
165
- return data;
166
- }
167
- else {
145
+ if (!this.depDataName) {
168
146
  throw new fsm_dynamo_1.Dynamo_Error({
169
147
  status: 501,
170
148
  errorCode: 'NTS-DBS-GD0',
171
149
  addECToUserMsg: true,
172
150
  message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
173
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
151
+ userMessage: this.defaultErrorUserMsg
174
152
  });
175
153
  }
154
+ let data = yield this.dataModel.findOne({ [this.depDataName]: dependencyId }).then(res => {
155
+ if (res) {
156
+ return res.toObject();
157
+ }
158
+ else {
159
+ return null;
160
+ }
161
+ }).catch(error => {
162
+ throw new fsm_dynamo_1.Dynamo_Error({
163
+ status: 417,
164
+ errorCode: 'NTS-DBS-GD1',
165
+ addECToUserMsg: true,
166
+ message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
167
+ userMessage: this.defaultErrorUserMsg,
168
+ error
169
+ });
170
+ });
171
+ if (data && typeof data._id === 'object') {
172
+ data._id = `${data._id}`;
173
+ }
174
+ return data;
176
175
  });
177
176
  }
178
177
  /**
@@ -182,38 +181,35 @@ class DynamoNTS_DBService {
182
181
  */
183
182
  getDataListByDependencyId(dependencyId) {
184
183
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
185
- if (this.depDataName) {
186
- let dataList = [];
187
- yield this.dataModel.find({ [this.depDataName]: dependencyId }).then(res => {
188
- if (res) {
189
- dataList = res;
190
- }
191
- }).catch(error => {
192
- throw new fsm_dynamo_1.Dynamo_Error({
193
- status: 417,
194
- errorCode: 'NTS-DBS-GLD1',
195
- addECToUserMsg: true,
196
- message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
197
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
198
- error
199
- });
200
- });
201
- if (0 < dataList.length && typeof dataList[0]._id === 'object') {
202
- dataList.forEach((data) => {
203
- data._id = `˙${data._id}`;
204
- });
205
- }
206
- return dataList;
207
- }
208
- else {
184
+ if (!this.depDataName) {
209
185
  throw new fsm_dynamo_1.Dynamo_Error({
210
186
  status: 501,
211
187
  errorCode: 'NTS-DBS-GLD0',
212
188
  addECToUserMsg: true,
213
189
  message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
214
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
190
+ userMessage: this.defaultErrorUserMsg
215
191
  });
216
192
  }
193
+ let dataList = yield this.dataModel.find({ [this.depDataName]: dependencyId })
194
+ .then(res => res !== null && res !== void 0 ? res : [])
195
+ .catch(error => {
196
+ throw new fsm_dynamo_1.Dynamo_Error({
197
+ status: 417,
198
+ errorCode: 'NTS-DBS-GLD1',
199
+ addECToUserMsg: true,
200
+ message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
201
+ userMessage: this.defaultErrorUserMsg,
202
+ error
203
+ });
204
+ });
205
+ if (0 < dataList.length) {
206
+ dataList.forEach((data) => {
207
+ if (data && typeof data._id === 'object') {
208
+ data._id = `${data._id}`;
209
+ }
210
+ });
211
+ }
212
+ return dataList;
217
213
  });
218
214
  }
219
215
  /**
@@ -223,33 +219,35 @@ class DynamoNTS_DBService {
223
219
  */
224
220
  getDataListByDependencyIds(ids) {
225
221
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
226
- if (this.depDataName) {
227
- let dataList = [];
228
- yield this.dataModel.find({ [this.depDataName]: { $in: ids } }).then(res => {
229
- if (res) {
230
- dataList = res;
231
- }
232
- }).catch(error => {
233
- throw new fsm_dynamo_1.Dynamo_Error({
234
- status: 417,
235
- errorCode: 'NTS-DBS-GLDS1',
236
- addECToUserMsg: true,
237
- message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (NTS DB)`,
238
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
239
- error
240
- });
241
- });
242
- return dataList;
243
- }
244
- else {
222
+ if (!this.depDataName) {
245
223
  throw new fsm_dynamo_1.Dynamo_Error({
246
224
  status: 501,
247
225
  errorCode: 'NTS-DBS-GLDS0',
248
226
  addECToUserMsg: true,
249
227
  message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
250
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
228
+ userMessage: this.defaultErrorUserMsg
229
+ });
230
+ }
231
+ let dataList = yield this.dataModel.find({ [this.depDataName]: { $in: ids } })
232
+ .then(res => res !== null && res !== void 0 ? res : [])
233
+ .catch(error => {
234
+ throw new fsm_dynamo_1.Dynamo_Error({
235
+ status: 417,
236
+ errorCode: 'NTS-DBS-GLDS1',
237
+ addECToUserMsg: true,
238
+ message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (NTS DB)`,
239
+ userMessage: this.defaultErrorUserMsg,
240
+ error
241
+ });
242
+ });
243
+ if (0 < dataList.length) {
244
+ dataList.forEach((data) => {
245
+ if (data && typeof data._id === 'object') {
246
+ data._id = `${data._id}`;
247
+ }
251
248
  });
252
249
  }
250
+ return dataList;
253
251
  });
254
252
  }
255
253
  /**
@@ -262,27 +260,27 @@ class DynamoNTS_DBService {
262
260
  searchData(searchBy, narrowByDependencyIds) {
263
261
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
264
262
  const filter = {};
265
- if (narrowByDependencyIds.length > 0) {
266
- if (this.depDataName) {
267
- filter[this.depDataName] = { $in: narrowByDependencyIds };
268
- }
269
- else {
263
+ if (0 < narrowByDependencyIds.length) {
264
+ if (!this.depDataName) {
270
265
  throw new fsm_dynamo_1.Dynamo_Error({
271
266
  status: 501,
272
267
  errorCode: 'NTS-DBS-SD0',
273
268
  addECToUserMsg: true,
274
269
  message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
275
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
270
+ userMessage: this.defaultErrorUserMsg
276
271
  });
277
272
  }
273
+ filter[this.depDataName] = { $in: narrowByDependencyIds };
278
274
  }
279
275
  yield this.dataParams.modelParams.forEach((modelParam) => {
280
- if ((searchBy[modelParam.key] !== null && searchBy[modelParam.key] !== undefined) || searchBy[modelParam.key + 'Range']) {
276
+ if ((searchBy[modelParam.key] !== null && searchBy[modelParam.key] !== undefined) ||
277
+ searchBy[modelParam.key + 'Range']) {
281
278
  if (modelParam.key.includes('Range') || modelParam.type.includes('[]')) {
282
279
  // inverz search filter (for Range and Array functions)
283
280
  if (modelParam.key.includes('Range')) {
284
281
  const searchParamKeyWithoutRange = modelParam.key.split('Range')[0];
285
- if (searchBy[searchParamKeyWithoutRange] !== null && searchBy[searchParamKeyWithoutRange] !== undefined) {
282
+ if (searchBy[searchParamKeyWithoutRange] !== null &&
283
+ searchBy[searchParamKeyWithoutRange] !== undefined) {
286
284
  filter[modelParam.key] = {
287
285
  from: { $lte: searchBy[searchParamKeyWithoutRange] },
288
286
  to: { $gte: searchBy[searchParamKeyWithoutRange] }
@@ -290,7 +288,8 @@ class DynamoNTS_DBService {
290
288
  }
291
289
  }
292
290
  else {
293
- if (searchBy[modelParam.key] !== null && searchBy[modelParam.key] !== undefined) {
291
+ if (searchBy[modelParam.key] !== null &&
292
+ searchBy[modelParam.key] !== undefined) {
294
293
  filter[modelParam.key] = { $in: searchBy[modelParam.key] };
295
294
  }
296
295
  }
@@ -316,74 +315,43 @@ class DynamoNTS_DBService {
316
315
  }
317
316
  }
318
317
  });
319
- let dataList = [];
320
- yield this.dataModel.find(filter).then(res => {
321
- if (res) {
322
- dataList = res;
323
- }
324
- }).catch(error => {
318
+ let dataList = yield this.dataModel.find(filter)
319
+ .then(res => res !== null && res !== void 0 ? res : [])
320
+ .catch(error => {
325
321
  throw new fsm_dynamo_1.Dynamo_Error({
326
322
  status: 417,
327
323
  errorCode: 'NTS-DBS-SD1',
328
324
  addECToUserMsg: true,
329
325
  message: `search ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
330
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
326
+ userMessage: this.defaultErrorUserMsg,
331
327
  error
332
328
  });
333
329
  });
334
- if (0 < dataList.length && typeof dataList[0]._id === 'object') {
330
+ if (0 < dataList.length) {
335
331
  dataList.forEach((data) => {
336
- data._id = `˙${data._id}`;
332
+ if (data && typeof data._id === 'object') {
333
+ data._id = `${data._id}`;
334
+ }
337
335
  });
338
336
  }
339
337
  return dataList;
340
338
  });
341
339
  }
342
- /**
343
- * find data by any of its parameters, throws error if not found
344
- * @param data
345
- * (always use unique parameters for find!)
346
- * etc.: by email:
347
- * @example { email: email }
348
- * or by id that is in list:
349
- * @example { userIds: { $in: this.userId } }
350
- * or by number or Date that is greater than OR less than:
351
- * @example { points: { $gte: 2, $lte: 14 } }
352
- * @returns data
353
- */
354
- /* async findData(data: T): Promise<T> {
355
- await this.dataModel.findOne(data).then(res => {
356
- if (res) {
357
- data = res.toObject() as T;
358
- } else {
359
- data = null;
360
- }
361
- }).catch(error => {
362
- throw new Dynamo_Error({ status: 417, message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`, error });
363
- });
364
- if (data && typeof data._id === 'object') {
365
- data._id = `${data._id}`;
366
- }
367
- return data;
368
- } */
369
340
  /**
370
341
  * returns all data from database, throws error if not found
371
342
  * @returns dataList
372
343
  */
373
344
  getAll() {
374
345
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
375
- let dataList = [];
376
- yield this.dataModel.find({}).then(res => {
377
- if (res) {
378
- dataList = res;
379
- }
380
- }).catch(error => {
346
+ let dataList = yield this.dataModel.find({})
347
+ .then(res => res !== null && res !== void 0 ? res : [])
348
+ .catch(error => {
381
349
  throw new fsm_dynamo_1.Dynamo_Error({
382
350
  status: 417,
383
351
  errorCode: 'NTS-DBS-GA0',
384
352
  addECToUserMsg: true,
385
353
  message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
386
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
354
+ userMessage: this.defaultErrorUserMsg,
387
355
  error
388
356
  });
389
357
  });
@@ -407,7 +375,7 @@ class DynamoNTS_DBService {
407
375
  errorCode: 'NTS-DBS-DD0',
408
376
  addECToUserMsg: true,
409
377
  message: `delete ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
410
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
378
+ userMessage: this.defaultErrorUserMsg,
411
379
  error
412
380
  });
413
381
  });
@@ -419,61 +387,64 @@ class DynamoNTS_DBService {
419
387
  */
420
388
  deleteDataByDependencyId(dependencyId) {
421
389
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
422
- if (this.depDataName) {
423
- yield this.dataModel.deleteMany({ [this.depDataName]: dependencyId }).catch(error => {
424
- throw new fsm_dynamo_1.Dynamo_Error({
425
- status: 417,
426
- errorCode: 'NTS-DBS-DDD1',
427
- addECToUserMsg: true,
428
- message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
429
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
430
- error
431
- });
432
- });
433
- }
434
- else {
390
+ if (!this.depDataName) {
435
391
  throw new fsm_dynamo_1.Dynamo_Error({
436
392
  status: 501,
437
393
  errorCode: 'NTS-DBS-DDD0',
438
394
  addECToUserMsg: true,
439
395
  message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
440
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
396
+ userMessage: this.defaultErrorUserMsg
441
397
  });
442
398
  }
399
+ yield this.dataModel.deleteMany({ [this.depDataName]: dependencyId })
400
+ .catch(error => {
401
+ throw new fsm_dynamo_1.Dynamo_Error({
402
+ status: 417,
403
+ errorCode: 'NTS-DBS-DDD1',
404
+ addECToUserMsg: true,
405
+ message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
406
+ userMessage: this.defaultErrorUserMsg,
407
+ error
408
+ });
409
+ });
443
410
  });
444
411
  }
445
412
  // ----------------------------------------------------------------------------------
446
413
  // ----------------------------------------------------------------------------------
447
414
  // ----------------------------------------------------------------------------------
448
- // DIRECT MONGOOSE CALLS (with error handlings)
415
+ // DIRECT Basic MONGOOSE FUNCTIONS (with error handlings)
449
416
  /**
450
- * find the data first by any of its parameters, throws error if not found
451
- * @param filter
452
- * (always use unique parameters for find!)
453
- * etc.: by email:
454
- * @example { email: email }
455
- * or by id that is in list:
456
- * @example { userIds: { $in: this.userId } }
457
- * or by number or Date that is GREATER THAN OR LESS THAN:
458
- * @example { points: { $gt: 2, $lt: 14 } }
459
- * further tools (syntax matches with $gt):
460
- * $eq: Matches values that are EQUAL to a specified value.
461
- * $gte: Matches values that are GREATER THAN or EQUAL to a specified value.
462
- * $lte: Matches values that are LESS THAN or EQUAL to a specified value.
463
- * $ne: Matches all values that are NOT EQUAL to a specified value.
464
- * $nin: Matches NONE of the values specified IN an array.
417
+ * Find the data first by any of its parameters, throws error if not found
418
+ * @param filter if you can, use unique parameters for find!
465
419
  *
466
- * @returns data
420
+ * @example
421
+ * // by email:
422
+ * { email: email }
423
+ * //
424
+ * @example
425
+ * // or by id that is in list:
426
+ * { userIds: { $in: this.userId } }
427
+ * //
428
+ * @example
429
+ * // or by number or Date that is Greater Than AND Less Than:
430
+ * { points: { $gt: 2, $lt: 14 } }
431
+ * // further tools (syntax matches with $gt):
432
+ * $eq: // Matches values that are EQual to a specified value.
433
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
434
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
435
+ * $ne: // Matches all values that are Not Equal to a specified value.
436
+ * $nin: // Matches None of the values specified IN an array.
437
+ * //
438
+ * @returns {T} data: T
467
439
  */
468
440
  findOne(filter) {
469
441
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
470
- let data;
471
- yield this.dataModel.findOne(filter).then(res => {
442
+ let data = yield this.dataModel.findOne(filter).then(res => {
472
443
  if (res) {
473
- data = res.toObject();
444
+ return res.toObject();
474
445
  }
475
446
  else {
476
- data = null;
447
+ return null;
477
448
  }
478
449
  }).catch(error => {
479
450
  throw new fsm_dynamo_1.Dynamo_Error({
@@ -481,7 +452,7 @@ class DynamoNTS_DBService {
481
452
  errorCode: 'NTS-DBS-FO0',
482
453
  addECToUserMsg: true,
483
454
  message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
484
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
455
+ userMessage: this.defaultErrorUserMsg,
485
456
  error
486
457
  });
487
458
  });
@@ -492,93 +463,106 @@ class DynamoNTS_DBService {
492
463
  });
493
464
  }
494
465
  /**
495
- * find all data by any of its parameters, throws error if not found
496
- * @param filter
497
- * etc.: by email:
498
- * @example { email: email }
499
- * or by id that is in list:
500
- * @example { userIds: { $in: this.userId } }
501
- * or by number or Date that is GREATER THAN OR LESS THAN:
502
- * @example { points: { $gt: 2, $lt: 14 } }
503
- * further tools (syntax matches with $gt):
504
- * $eq: Matches values that are EQUAL to a specified value.
505
- * $gte: Matches values that are GREATER THAN or EQUAL to a specified value.
506
- * $lte: Matches values that are LESS THAN or EQUAL to a specified value.
507
- * $ne: Matches all values that are NOT EQUAL to a specified value.
508
- * $nin: Matches NONE of the values specified IN an array.
466
+ * Find the data first by any of its parameters, throws error if not found
467
+ * @param filter if you can, use unique parameters for find!
509
468
  *
510
- * @returns dataList
469
+ * @example
470
+ * // by email:
471
+ * { email: email }
472
+ * //
473
+ * @example
474
+ * // or by id that is in list:
475
+ * { userIds: { $in: this.userId } }
476
+ * //
477
+ * @example
478
+ * // or by number or Date that is Greater Than AND Less Than:
479
+ * { points: { $gt: 2, $lt: 14 } }
480
+ * // further tools (syntax matches with $gt):
481
+ * $eq: // Matches values that are EQual to a specified value.
482
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
483
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
484
+ * $ne: // Matches all values that are Not Equal to a specified value.
485
+ * $nin: // Matches None of the values specified IN an array.
486
+ * //
487
+ * @returns {T[]} dataList: T[]
511
488
  */
512
489
  find(filter) {
513
490
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
514
- let dataList = [];
515
- yield this.dataModel.find(filter).then(res => {
516
- if (res) {
517
- dataList = res;
518
- }
519
- }).catch(error => {
491
+ let dataList = yield this.dataModel.find(filter)
492
+ .then(res => res !== null && res !== void 0 ? res : [])
493
+ .catch(error => {
520
494
  throw new fsm_dynamo_1.Dynamo_Error({
521
495
  status: 417,
522
496
  errorCode: 'NTS-DBS-F0',
523
497
  addECToUserMsg: true,
524
498
  message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
525
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
499
+ userMessage: this.defaultErrorUserMsg,
526
500
  error
527
501
  });
528
502
  });
529
- if (0 < dataList.length && typeof dataList[0]._id === 'object') {
503
+ if (0 < dataList.length) {
530
504
  dataList.forEach((data) => {
531
- data._id = `˙${data._id}`;
505
+ if (data && typeof data._id === 'object') {
506
+ data._id = `${data._id}`;
507
+ }
532
508
  });
533
509
  }
534
510
  return dataList;
535
511
  });
536
512
  }
537
513
  /**
538
- * find all data by any of its parameters, throws error if not found
539
- * @param filter
540
- * etc.: by email:
541
- * @example { email: email }
542
- * or by id that is in list:
543
- * @example { userIds: { $in: this.userId } }
544
- * or by number or Date that is GREATER THAN OR LESS THAN:
545
- * @example { points: { $gt: 2, $lt: 14 } }
546
- * further tools (syntax matches with $gt):
547
- * $eq: Matches values that are EQUAL to a specified value.
548
- * $gte: Matches values that are GREATER THAN or EQUAL to a specified value.
549
- * $lte: Matches values that are LESS THAN or EQUAL to a specified value.
550
- * $ne: Matches all values that are NOT EQUAL to a specified value.
551
- * $nin: Matches NONE of the values specified IN an array.
514
+ * Find the data first by any of its parameters, throws error if not found
515
+ * @param filter if you can, use unique parameters for find!
552
516
  *
517
+ * @example
518
+ * // by email:
519
+ * { email: email }
520
+ * //
521
+ * @example
522
+ * // or by id that is in list:
523
+ * { userIds: { $in: this.userId } }
524
+ * //
525
+ * @example
526
+ * // or by number or Date that is Greater Than AND Less Than:
527
+ * { points: { $gt: 2, $lt: 14 } }
528
+ * // further tools (syntax matches with $gt):
529
+ * $eq: // Matches values that are EQual to a specified value.
530
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
531
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
532
+ * $ne: // Matches all values that are Not Equal to a specified value.
533
+ * $nin: // Matches None of the values specified IN an array.
534
+ * //
553
535
  * @param page page
554
536
  * @param pageSize pageSize
555
- * @param sort etc. by dateTime: { dateTime: -1 }
556
- * @returns dataList
537
+ * @param sort
538
+ * @example
539
+ * // by dateTime (this uses the basic sort function):
540
+ * { dateTime: -1 }
541
+ * //
542
+ * @returns {T[]} dataList: T[]
557
543
  */
558
544
  findWithPaging(filter, page, pageSize, sort) {
559
545
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
560
- let dataList = [];
561
- yield this.dataModel.find(filter)
546
+ let dataList = yield this.dataModel.find(filter)
562
547
  .sort(sort)
563
548
  .skip(page * pageSize)
564
549
  .limit(pageSize)
565
- .then(res => {
566
- if (res) {
567
- dataList = res;
568
- }
569
- }).catch(error => {
550
+ .then(res => res !== null && res !== void 0 ? res : [])
551
+ .catch(error => {
570
552
  throw new fsm_dynamo_1.Dynamo_Error({
571
553
  status: 417,
572
554
  errorCode: 'NTS-DBS-WP0',
573
555
  addECToUserMsg: true,
574
556
  message: `findWithPaging ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
575
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
557
+ userMessage: this.defaultErrorUserMsg,
576
558
  error
577
559
  });
578
560
  });
579
- if (0 < dataList.length && typeof dataList[0]._id === 'object') {
561
+ if (0 < dataList.length) {
580
562
  dataList.forEach((data) => {
581
- data._id = `˙${data._id}`;
563
+ if (data && typeof data._id === 'object') {
564
+ data._id = `${data._id}`;
565
+ }
582
566
  });
583
567
  }
584
568
  return dataList;
@@ -592,12 +576,11 @@ class DynamoNTS_DBService {
592
576
  */
593
577
  findByIdAndUpdate(id, update, modifier) {
594
578
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
595
- let data;
596
579
  update.__lastModified = new Date();
597
580
  update.__lastModifiedBy = modifier;
598
- yield this.dataModel.findByIdAndUpdate(id, update).then(res => {
581
+ let newData = yield this.dataModel.findByIdAndUpdate(id, update).then(res => {
599
582
  if (res) {
600
- data = res.toObject();
583
+ return res.toObject();
601
584
  }
602
585
  else {
603
586
  throw new fsm_dynamo_1.Dynamo_Error({
@@ -605,7 +588,7 @@ class DynamoNTS_DBService {
605
588
  errorCode: 'NTS-DBS-FIU1',
606
589
  addECToUserMsg: true,
607
590
  message: `${this.dataParams.dbName} not found! (NTS DB)`,
608
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
591
+ userMessage: this.defaultErrorUserMsg
609
592
  });
610
593
  }
611
594
  }).catch(error => {
@@ -614,107 +597,178 @@ class DynamoNTS_DBService {
614
597
  errorCode: 'NTS-DBS-FIU0',
615
598
  addECToUserMsg: true,
616
599
  message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
617
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
600
+ userMessage: this.defaultErrorUserMsg,
618
601
  error
619
602
  });
620
603
  });
621
- update.__v = data.__v;
622
- return update;
604
+ if (typeof newData._id === 'object') {
605
+ newData._id = `${newData._id}`;
606
+ }
607
+ /* update._id = newData._id;
608
+ update.__v = newData.__v; */
609
+ return newData;
623
610
  });
624
611
  }
625
612
  /**
626
- * update one parameter by a specific
627
- * @param updateBy
628
- * (always use unique parameters for find!)
629
- * etc.: by email:
630
- * @example { email: email }
631
- * or by id that is in list:
632
- * @example { userIds: { $in: this.userId } }
633
- * or by number or Date that is GREATER THAN OR LESS THAN:
634
- * @example { points: { $gt: 2, $lt: 14 } }
635
- * further tools (syntax matches with $gt):
636
- * $eq: Matches values that are EQUAL to a specified value.
637
- * $gte: Matches values that are GREATER THAN or EQUAL to a specified value.
638
- * $lte: Matches values that are LESS THAN or EQUAL to a specified value.
639
- * $ne: Matches all values that are NOT EQUAL to a specified value.
640
- * $nin: Matches NONE of the values specified IN an array.
613
+ * Find the data first by any of its parameters, throws error if not found
614
+ * @param filter This uses the basic Mongoose updateOne.
615
+ * If you can, use unique parameters for find!
616
+ * @example
617
+ * // by email:
618
+ * { email: email }
619
+ * //
620
+ * @example
621
+ * // or by id that is in list:
622
+ * { userIds: { $in: this.userId } }
623
+ * //
624
+ * @example
625
+ * // or by number or Date that is Greater Than AND Less Than:
626
+ * { points: { $gt: 2, $lt: 14 } }
627
+ * // further tools (syntax matches with $gt):
628
+ * $eq: // Matches values that are EQual to a specified value.
629
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
630
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
631
+ * $ne: // Matches all values that are Not Equal to a specified value.
632
+ * $nin: // Matches None of the values specified IN an array.
633
+ * //
641
634
  *
642
- * @param update
643
- * etc.: increase a specific value:
644
- * @example { $inc: { popularity: 15 } }
645
- * or add element to a list:
646
- * @example { $push: { reactions: this.newReaction }
647
- * or all at once
648
- * @example { $inc: { popularity: this.newVote.amount }, emailVerified: true, $push: { reactions: this.newReaction } }
649
- * further tools (syntax matches with $inc):
650
- * $currentDate: Sets the value of a field to current date, either as a Date or a Timestamp.
651
- * $min: Only updates the field if the specified value is less than the existing field value.
652
- * $max: Only updates the field if the specified value is greater than the existing field value.
653
- * $mul: Multiplies the value of the field by the specified amount.
654
- * $rename: Renames a field.
655
- * $unset: Removes the specified field from a document. (set: "" to value)
635
+ * @param update this uses the basic Mongoose updateOne
636
+ * @example
637
+ * // increase a specific value (here by 15):
638
+ * { $inc: { popularity: 15 } }
639
+ * //
640
+ * @example
641
+ * // or add element to a list:
642
+ * { $push: { reactions: this.newReaction }
643
+ * // or add multiple elements to a list
644
+ * { $push: { schedule: {$each: [ monday, tuesday, wednesday ] } } }
645
+ * //
646
+ * @example
647
+ * // or all at once
648
+ * {
649
+ * $inc: { popularity: this.newVote.amount },
650
+ * emailVerified: true,
651
+ * $push: { reactions: this.newReaction }
652
+ * }
653
+ * // further tools (syntax matches with $inc):
654
+ * $currentDate: // Sets the value of a field to current date, either as a Date or a Timestamp.
655
+ * $min: // Only updates the field if the specified value is less than the existing field value.
656
+ * $max: // Only updates the field if the specified value is greater than the existing field value.
657
+ * $mul: // Multiplies the value of the field by the specified amount.
658
+ * $rename: // Renames a field.
659
+ * $unset: // Removes the specified field from a document. (set: "" to value)
660
+ * //
656
661
  */
657
662
  updateOne(updateBy, update, modifier) {
658
663
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
659
664
  update.__lastModified = new Date();
660
665
  update.__lastModifiedBy = modifier;
661
- yield this.dataModel.updateOne(updateBy, update).catch(error => {
666
+ let newData = yield this.dataModel.updateOne(updateBy, update).then(res => {
667
+ if (res) {
668
+ return res.toObject();
669
+ }
670
+ else {
671
+ throw new fsm_dynamo_1.Dynamo_Error({
672
+ status: 204,
673
+ errorCode: 'NTS-DBS-FU1',
674
+ addECToUserMsg: true,
675
+ message: `update ${this.dataParams.dbName} result not found! (NTS DB)`,
676
+ userMessage: this.defaultErrorUserMsg
677
+ });
678
+ }
679
+ }).catch(error => {
662
680
  throw new fsm_dynamo_1.Dynamo_Error({
663
681
  status: 417,
664
682
  errorCode: 'NTS-DBS-UO0',
665
683
  addECToUserMsg: true,
666
684
  message: `updateOne ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
667
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
685
+ userMessage: this.defaultErrorUserMsg,
668
686
  error
669
687
  });
670
688
  });
689
+ if (typeof newData._id === 'object') {
690
+ newData._id = `${newData._id}`;
691
+ }
692
+ /* update._id = newData._id;
693
+ update.__v = newData.__v; */
694
+ console.log(`Dynamo function result under testing: ${newData}`);
695
+ return newData;
671
696
  });
672
697
  }
673
698
  /**
674
699
  * update one parameter by a specific
675
- * @param updateBy
676
- * etc.: by email:
677
- * @example { email: email }
678
- * or by id that is in list:
679
- * @example { userIds: { $in: this.userId } }
680
- * or by number or Date that is GREATER THAN OR LESS THAN:
681
- * @example { points: { $gt: 2, $lt: 14 } }
682
- * further tools (syntax matches with $gt):
683
- * $eq: Matches values that are EQUAL to a specified value.
684
- * $gte: Matches values that are GREATER THAN or EQUAL to a specified value.
685
- * $lte: Matches values that are LESS THAN or EQUAL to a specified value.
686
- * $ne: Matches all values that are NOT EQUAL to a specified value.
687
- * $nin: Matches NONE of the values specified IN an array.
700
+ * @param filter This uses the basic Mongoose updateMany.
701
+ * @example
702
+ * // by email:
703
+ * { email: email }
704
+ * //
705
+ * @example
706
+ * // or by id that is in list:
707
+ * { userIds: { $in: this.userId } }
708
+ * //
709
+ * @example
710
+ * // or by number or Date that is Greater Than AND Less Than:
711
+ * { points: { $gt: 2, $lt: 14 } }
712
+ * // further tools (syntax matches with $gt):
713
+ * $eq: // Matches values that are EQual to a specified value.
714
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
715
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
716
+ * $ne: // Matches all values that are Not Equal to a specified value.
717
+ * $nin: // Matches None of the values specified IN an array.
718
+ * //
688
719
  *
689
- * @param update
690
- * etc.: increase a specific value:
691
- * @example { $inc: { popularity: 15 } }
692
- * or add element to a list:
693
- * @example { $push: { reactions: this.newReaction }
694
- * or all at once
695
- * @example { $inc: { popularity: this.newVote.amount }, emailVerified: true, $push: { reactions: this.newReaction } }
696
- * further tools (syntax matches with $inc):
697
- * $currentDate: Sets the value of a field to current date, either as a Date or a Timestamp.
698
- * $min: Only updates the field if the specified value is less than the existing field value.
699
- * $max: Only updates the field if the specified value is greater than the existing field value.
700
- * $mul: Multiplies the value of the field by the specified amount.
701
- * $rename: Renames a field.
702
- * $unset: Removes the specified field from a document. (set: "" to value)
720
+ * @param update this uses the basic Mongoose updateOne
721
+ * @example
722
+ * // increase a specific value (here by 15):
723
+ * { $inc: { popularity: 15 } }
724
+ * //
725
+ * @example
726
+ * // or add element to a list:
727
+ * { $push: { reactions: this.newReaction }
728
+ * // or add multiple elements to a list
729
+ * { $push: { schedule: {$each: [ monday, tuesday, wednesday ] } } }
730
+ * //
731
+ * @example
732
+ * // or all at once
733
+ * {
734
+ * $inc: { popularity: this.newVote.amount },
735
+ * emailVerified: true,
736
+ * $push: { reactions: this.newReaction }
737
+ * }
738
+ * // further tools (syntax matches with $inc):
739
+ * $currentDate: // Sets the value of a field to current date, either as a Date or a Timestamp.
740
+ * $min: // Only updates the field if the specified value is less than the existing field value.
741
+ * $max: // Only updates the field if the specified value is greater than the existing field value.
742
+ * $mul: // Multiplies the value of the field by the specified amount.
743
+ * $rename: // Renames a field.
744
+ * $unset: // Removes the specified field from a document. (set: "" to value)
745
+ * //
703
746
  */
704
747
  updateMany(updateBy, update, modifier) {
705
748
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
706
749
  update.__lastModified = new Date();
707
750
  update.__lastModifiedBy = modifier;
708
- yield this.dataModel.updateMany(updateBy, update).catch(error => {
751
+ let dataList = yield this.dataModel.updateMany(updateBy, update)
752
+ .then(res => res !== null && res !== void 0 ? res : [])
753
+ .catch(error => {
709
754
  throw new fsm_dynamo_1.Dynamo_Error({
710
755
  status: 417,
711
756
  errorCode: 'NTS-DBS-UM0',
712
757
  addECToUserMsg: true,
713
758
  message: `updateMany ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
714
- userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
759
+ userMessage: this.defaultErrorUserMsg,
715
760
  error
716
761
  });
717
762
  });
763
+ if (0 < dataList.length) {
764
+ dataList.forEach((data) => {
765
+ if (data && typeof data._id === 'object') {
766
+ data._id = `${data._id}`;
767
+ }
768
+ });
769
+ }
770
+ console.log(`Dynamo function result under testing: ${dataList}`);
771
+ return dataList;
718
772
  });
719
773
  }
720
774
  // ----------------------------------------------------------------------------------
@@ -746,8 +800,9 @@ class DynamoNTS_DBService {
746
800
  params = this.dataParams.modelParams;
747
801
  }
748
802
  params.forEach((property) => {
803
+ var _a;
749
804
  const beType = this.getBEType(property.type);
750
- if (beType !== Object || !property.subObjectParams) {
805
+ if (beType !== Object || !(property === null || property === void 0 ? void 0 : property.subObjectParams) || ((_a = property === null || property === void 0 ? void 0 : property.subObjectParams) === null || _a === void 0 ? void 0 : _a.length) == 0) {
751
806
  schemaSettingsObj[property.key] = {
752
807
  type: beType
753
808
  };