@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.
- package/lib/_models/dynamo-nts-endpoint-params.js +3 -2
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
- package/lib/_services/dynamo-nts-api.service.d.ts +1 -0
- package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-api.service.js +6 -5
- package/lib/_services/dynamo-nts-api.service.js.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts +87 -7
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +87 -7
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +131 -22
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +104 -1
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.d.ts +79 -5
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.js +3 -2
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +25 -1
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +98 -70
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db.service.d.ts +165 -119
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +348 -293
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-email.service.d.ts +1 -0
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-email.service.js +5 -4
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.d.ts +40 -0
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js +43 -3
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.d.ts +1 -0
- package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +6 -2
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -12
- package/src/_models/dynamo-nts-endpoint-params.ts +2 -2
- package/src/_services/dynamo-nts-api.service.ts +7 -5
- package/src/_services/dynamo-nts-app-extended.ts +87 -7
- package/src/_services/dynamo-nts-app.ts +131 -22
- package/src/_services/dynamo-nts-auth.service.ts +83 -7
- package/src/_services/dynamo-nts-data.service.ts +100 -71
- package/src/_services/dynamo-nts-db.service.ts +377 -297
- package/src/_services/dynamo-nts-email.service.ts +6 -4
- package/src/_services/dynamo-nts-routing-module.service.ts +44 -3
- package/src/_services/dynamo-nts-socket.service.ts +13 -7
- package/futdevpro-nts-dynamo-01.05.40.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.41.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.42.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.43.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.44.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.45.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.47.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.49.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.50.tgz +0 -0
- package/lib/_constants/dynamo-nts-global.settings.d.ts +0 -3
- package/lib/_constants/dynamo-nts-global.settings.d.ts.map +0 -1
- package/lib/_constants/dynamo-nts-global.settings.js +0 -18
- package/lib/_constants/dynamo-nts-global.settings.js.map +0 -1
- package/lib/_constants/dynamobe-global.settings.d.ts +0 -3
- package/lib/_constants/dynamobe-global.settings.d.ts.map +0 -1
- package/lib/_constants/dynamobe-global.settings.js +0 -13
- package/lib/_constants/dynamobe-global.settings.js.map +0 -1
- package/lib/_enums/dynamobe-data-service-function.enum.d.ts +0 -8
- package/lib/_enums/dynamobe-data-service-function.enum.d.ts.map +0 -1
- package/lib/_enums/dynamobe-data-service-function.enum.js +0 -15
- package/lib/_enums/dynamobe-data-service-function.enum.js.map +0 -1
- package/lib/_enums/dynamobe-route-security.enum.d.ts +0 -6
- package/lib/_enums/dynamobe-route-security.enum.d.ts.map +0 -1
- package/lib/_enums/dynamobe-route-security.enum.js +0 -10
- package/lib/_enums/dynamobe-route-security.enum.js.map +0 -1
- package/lib/_enums/log-style.enum.d.ts +0 -26
- package/lib/_enums/log-style.enum.d.ts.map +0 -1
- package/lib/_enums/log-style.enum.js +0 -30
- package/lib/_enums/log-style.enum.js.map +0 -1
- package/lib/_models/dynamo-module-settings.d.ts +0 -4
- package/lib/_models/dynamo-module-settings.d.ts.map +0 -1
- package/lib/_models/dynamo-module-settings.js +0 -10
- package/lib/_models/dynamo-module-settings.js.map +0 -1
- package/lib/_models/dynamo-nts-socket-module-settings.d.ts +0 -19
- package/lib/_models/dynamo-nts-socket-module-settings.d.ts.map +0 -1
- package/lib/_models/dynamo-nts-socket-module-settings.js +0 -27
- package/lib/_models/dynamo-nts-socket-module-settings.js.map +0 -1
- package/lib/_models/dynamobe-api-call-params.d.ts +0 -37
- package/lib/_models/dynamobe-api-call-params.d.ts.map +0 -1
- package/lib/_models/dynamobe-api-call-params.js +0 -29
- package/lib/_models/dynamobe-api-call-params.js.map +0 -1
- package/lib/_models/dynamobe-app-params.d.ts +0 -18
- package/lib/_models/dynamobe-app-params.d.ts.map +0 -1
- package/lib/_models/dynamobe-app-params.js +0 -17
- package/lib/_models/dynamobe-app-params.js.map +0 -1
- package/lib/_models/dynamobe-data-model-params.d.ts +0 -1
- package/lib/_models/dynamobe-data-model-params.d.ts.map +0 -1
- package/lib/_models/dynamobe-data-model-params.js +0 -25
- package/lib/_models/dynamobe-data-model-params.js.map +0 -1
- package/lib/_models/dynamobe-endpoint-params.d.ts +0 -46
- package/lib/_models/dynamobe-endpoint-params.d.ts.map +0 -1
- package/lib/_models/dynamobe-endpoint-params.js +0 -117
- package/lib/_models/dynamobe-endpoint-params.js.map +0 -1
- package/lib/_models/dynamobe-global-settings.d.ts +0 -13
- package/lib/_models/dynamobe-global-settings.d.ts.map +0 -1
- package/lib/_models/dynamobe-global-settings.js +0 -3
- package/lib/_models/dynamobe-global-settings.js.map +0 -1
- package/lib/_modules/data-models.index.d.ts +0 -3
- package/lib/_modules/data-models.index.d.ts.map +0 -1
- package/lib/_modules/data-models.index.js +0 -6
- package/lib/_modules/data-models.index.js.map +0 -1
- package/lib/_services/dynamobe-api.service.d.ts +0 -19
- package/lib/_services/dynamobe-api.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-api.service.js +0 -167
- package/lib/_services/dynamobe-api.service.js.map +0 -1
- package/lib/_services/dynamobe-app.d.ts +0 -129
- package/lib/_services/dynamobe-app.d.ts.map +0 -1
- package/lib/_services/dynamobe-app.js +0 -238
- package/lib/_services/dynamobe-app.js.map +0 -1
- package/lib/_services/dynamobe-auth.service.d.ts +0 -54
- package/lib/_services/dynamobe-auth.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-auth.service.js +0 -46
- package/lib/_services/dynamobe-auth.service.js.map +0 -1
- package/lib/_services/dynamobe-controller.service.d.ts +0 -14
- package/lib/_services/dynamobe-controller.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-controller.service.js +0 -21
- package/lib/_services/dynamobe-controller.service.js.map +0 -1
- package/lib/_services/dynamobe-data.service.d.ts +0 -54
- package/lib/_services/dynamobe-data.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-data.service.js +0 -301
- package/lib/_services/dynamobe-data.service.js.map +0 -1
- package/lib/_services/dynamobe-db-service-collection.service.d.ts +0 -9
- package/lib/_services/dynamobe-db-service-collection.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-db-service-collection.service.js +0 -11
- package/lib/_services/dynamobe-db-service-collection.service.js.map +0 -1
- package/lib/_services/dynamobe-db.service.d.ts +0 -244
- package/lib/_services/dynamobe-db.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-db.service.js +0 -759
- package/lib/_services/dynamobe-db.service.js.map +0 -1
- package/lib/_services/dynamobe-email-service-collection.service.d.ts +0 -19
- package/lib/_services/dynamobe-email-service-collection.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-email-service-collection.service.js +0 -21
- package/lib/_services/dynamobe-email-service-collection.service.js.map +0 -1
- package/lib/_services/dynamobe-email.service.d.ts +0 -56
- package/lib/_services/dynamobe-email.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-email.service.js +0 -194
- package/lib/_services/dynamobe-email.service.js.map +0 -1
- package/lib/_services/dynamobe-global.service.d.ts +0 -62
- package/lib/_services/dynamobe-global.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-global.service.js +0 -107
- package/lib/_services/dynamobe-global.service.js.map +0 -1
- package/lib/_services/dynamobe-routing-module.service.d.ts +0 -42
- package/lib/_services/dynamobe-routing-module.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-routing-module.service.js +0 -146
- package/lib/_services/dynamobe-routing-module.service.js.map +0 -1
- package/lib/_services/dynamobe-shared-be.service.d.ts +0 -8
- package/lib/_services/dynamobe-shared-be.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-shared-be.service.js +0 -45
- package/lib/_services/dynamobe-shared-be.service.js.map +0 -1
- package/lib/_services/dynamobe-shared.service.d.ts +0 -26
- package/lib/_services/dynamobe-shared.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-shared.service.js +0 -63
- package/lib/_services/dynamobe-shared.service.js.map +0 -1
- package/lib/_services/dynamobe-singleton.service.d.ts +0 -9
- package/lib/_services/dynamobe-singleton.service.d.ts.map +0 -1
- package/lib/_services/dynamobe-singleton.service.js +0 -19
- 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
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
117
|
+
return res.toObject();
|
|
116
118
|
}
|
|
117
119
|
else {
|
|
118
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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:
|
|
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) ||
|
|
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 &&
|
|
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 &&
|
|
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
|
-
|
|
321
|
-
|
|
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:
|
|
326
|
+
userMessage: this.defaultErrorUserMsg,
|
|
331
327
|
error
|
|
332
328
|
});
|
|
333
329
|
});
|
|
334
|
-
if (0 < dataList.length
|
|
330
|
+
if (0 < dataList.length) {
|
|
335
331
|
dataList.forEach((data) => {
|
|
336
|
-
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
|
-
|
|
377
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
415
|
+
// DIRECT Basic MONGOOSE FUNCTIONS (with error handlings)
|
|
449
416
|
/**
|
|
450
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
444
|
+
return res.toObject();
|
|
474
445
|
}
|
|
475
446
|
else {
|
|
476
|
-
|
|
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:
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
516
|
-
|
|
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:
|
|
499
|
+
userMessage: this.defaultErrorUserMsg,
|
|
526
500
|
error
|
|
527
501
|
});
|
|
528
502
|
});
|
|
529
|
-
if (0 < dataList.length
|
|
503
|
+
if (0 < dataList.length) {
|
|
530
504
|
dataList.forEach((data) => {
|
|
531
|
-
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
|
-
*
|
|
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
|
|
556
|
-
* @
|
|
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
|
-
|
|
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:
|
|
557
|
+
userMessage: this.defaultErrorUserMsg,
|
|
576
558
|
error
|
|
577
559
|
});
|
|
578
560
|
});
|
|
579
|
-
if (0 < dataList.length
|
|
561
|
+
if (0 < dataList.length) {
|
|
580
562
|
dataList.forEach((data) => {
|
|
581
|
-
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
|
-
|
|
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:
|
|
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:
|
|
600
|
+
userMessage: this.defaultErrorUserMsg,
|
|
618
601
|
error
|
|
619
602
|
});
|
|
620
603
|
});
|
|
621
|
-
|
|
622
|
-
|
|
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
|
-
*
|
|
627
|
-
* @param
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
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
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
* $
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
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).
|
|
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:
|
|
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
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
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
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
* $
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
*
|
|
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)
|
|
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:
|
|
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
|
};
|