mocody 0.2.15 → 0.2.16
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/LICENSE +21 -21
- package/README.md +4 -4
- package/dist/core/base-schema.d.ts +13 -13
- package/dist/core/base-schema.js +11 -11
- package/dist/core/base-schema.js.map +1 -1
- package/dist/couch/couch-data-operation.d.ts +90 -90
- package/dist/couch/couch-data-operation.js +581 -581
- package/dist/couch/couch-data-operation.js.map +1 -1
- package/dist/couch/couch-filter-query-operation.d.ts +47 -47
- package/dist/couch/couch-filter-query-operation.js +438 -438
- package/dist/couch/couch-initializer.d.ts +45 -45
- package/dist/couch/couch-initializer.js +98 -98
- package/dist/couch/couch-initializer.js.map +1 -1
- package/dist/couch/couch-manage-table.d.ts +46 -46
- package/dist/couch/couch-manage-table.js +113 -113
- package/dist/dynamo/dynamo-data-operation.d.ts +97 -97
- package/dist/dynamo/dynamo-data-operation.js +788 -793
- package/dist/dynamo/dynamo-data-operation.js.map +1 -1
- package/dist/dynamo/dynamo-filter-query-operation.d.ts +28 -28
- package/dist/dynamo/dynamo-filter-query-operation.js +627 -627
- package/dist/dynamo/dynamo-helper.d.ts +1 -1
- package/dist/dynamo/dynamo-helper.js +8 -8
- package/dist/dynamo/dynamo-initializer.d.ts +14 -8
- package/dist/dynamo/dynamo-initializer.js +58 -34
- package/dist/dynamo/dynamo-initializer.js.map +1 -1
- package/dist/dynamo/dynamo-manage-table.d.ts +33 -32
- package/dist/dynamo/dynamo-manage-table.js +419 -418
- package/dist/dynamo/dynamo-manage-table.js.map +1 -1
- package/dist/dynamo/dynamo-query-scan-processor.d.ts +25 -24
- package/dist/dynamo/dynamo-query-scan-processor.js +268 -266
- package/dist/dynamo/dynamo-query-scan-processor.js.map +1 -1
- package/dist/helpers/base-joi-helper.d.ts +2 -2
- package/dist/helpers/base-joi-helper.js +12 -12
- package/dist/helpers/constants.d.ts +3 -3
- package/dist/helpers/constants.js +6 -6
- package/dist/helpers/errors.d.ts +13 -13
- package/dist/helpers/errors.js +38 -38
- package/dist/helpers/logging-service.d.ts +8 -8
- package/dist/helpers/logging-service.js +44 -44
- package/dist/helpers/mocody-utils.d.ts +13 -15
- package/dist/helpers/mocody-utils.js +48 -48
- package/dist/helpers/query-validator.d.ts +20 -20
- package/dist/helpers/query-validator.js +84 -84
- package/dist/helpers/util-service.d.ts +29 -29
- package/dist/helpers/util-service.js +155 -155
- package/dist/index.d.ts +10 -10
- package/dist/index.js +19 -19
- package/dist/model/index.d.ts +40 -40
- package/dist/model/index.js +6 -6
- package/dist/mongo/mongo-data-operation.d.ts +88 -88
- package/dist/mongo/mongo-data-operation.js +597 -597
- package/dist/mongo/mongo-data-operation.js.map +1 -1
- package/dist/mongo/mongo-filter-query-operation.d.ts +47 -47
- package/dist/mongo/mongo-filter-query-operation.js +433 -433
- package/dist/mongo/mongo-initializer.d.ts +16 -16
- package/dist/mongo/mongo-initializer.js +47 -47
- package/dist/mongo/mongo-initializer.js.map +1 -1
- package/dist/mongo/mongo-table-manager.d.ts +31 -31
- package/dist/mongo/mongo-table-manager.js +104 -104
- package/dist/type/index.d.ts +108 -108
- package/dist/type/index.js +2 -2
- package/package.json +70 -72
|
@@ -1,434 +1,434 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoFilterQueryOperation = void 0;
|
|
4
|
-
const logging_service_1 = require("./../helpers/logging-service");
|
|
5
|
-
const query_validator_1 = require("../helpers/query-validator");
|
|
6
|
-
const errors_1 = require("../helpers/errors");
|
|
7
|
-
const keyConditionMap = {
|
|
8
|
-
$eq: "$eq",
|
|
9
|
-
$lt: "$lt",
|
|
10
|
-
$lte: "$lte",
|
|
11
|
-
$gt: "$gt",
|
|
12
|
-
$gte: "$gte",
|
|
13
|
-
$between: "",
|
|
14
|
-
$beginsWith: "",
|
|
15
|
-
};
|
|
16
|
-
const conditionMapPre = {
|
|
17
|
-
$ne: "$ne",
|
|
18
|
-
$exists: "",
|
|
19
|
-
$in: "",
|
|
20
|
-
$nin: "",
|
|
21
|
-
$not: "",
|
|
22
|
-
$contains: "",
|
|
23
|
-
$notContains: "",
|
|
24
|
-
$elemMatch: "",
|
|
25
|
-
$nestedMatch: "",
|
|
26
|
-
};
|
|
27
|
-
const conditionMap = { ...keyConditionMap, ...conditionMapPre };
|
|
28
|
-
function hasQueryKeyCondition(key) {
|
|
29
|
-
return Object.keys(keyConditionMap).includes(key);
|
|
30
|
-
}
|
|
31
|
-
function getQueryConditionExpression(key) {
|
|
32
|
-
if (key && Object.keys(conditionMap).includes(key)) {
|
|
33
|
-
const conditionExpr = conditionMap[key];
|
|
34
|
-
if (conditionExpr) {
|
|
35
|
-
return conditionExpr;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
class MongoFilterQueryOperation {
|
|
41
|
-
operation__filterFieldExist({ fieldName }) {
|
|
42
|
-
const result = {
|
|
43
|
-
[fieldName]: { $exists: true },
|
|
44
|
-
};
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
operation__filterFieldNotExist({ fieldName }) {
|
|
48
|
-
const result = {
|
|
49
|
-
[fieldName]: { $exists: false },
|
|
50
|
-
};
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
operation__helperFilterBasic({ fieldName, val, conditionExpr, }) {
|
|
54
|
-
if (conditionExpr) {
|
|
55
|
-
return {
|
|
56
|
-
[fieldName]: { [conditionExpr]: val },
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const result = {
|
|
60
|
-
[fieldName]: { $eq: val },
|
|
61
|
-
};
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
operation__filterIn({ fieldName, attrValues }) {
|
|
65
|
-
const result = {
|
|
66
|
-
[fieldName]: { $in: attrValues },
|
|
67
|
-
};
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
operation__filterElementMatch({ fieldName, attrValues, }) {
|
|
71
|
-
const result = {
|
|
72
|
-
[fieldName]: {
|
|
73
|
-
$elemMatch: attrValues,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
operation__filterNotIn({ fieldName, attrValues, }) {
|
|
79
|
-
const result = {
|
|
80
|
-
[fieldName]: { $nin: attrValues },
|
|
81
|
-
};
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
operation__filterNot({ fieldName, selectorObjValues, }) {
|
|
85
|
-
const selector = { ...selectorObjValues };
|
|
86
|
-
const mConditions = [];
|
|
87
|
-
Object.entries(selector).forEach(([conditionKey, conditionValue]) => {
|
|
88
|
-
if (hasQueryKeyCondition(conditionKey)) {
|
|
89
|
-
const _conditionKey01 = conditionKey;
|
|
90
|
-
if (_conditionKey01 === "$beginsWith") {
|
|
91
|
-
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
92
|
-
const _queryConditions = this.operation__filterBeginsWith({
|
|
93
|
-
fieldName: fieldName,
|
|
94
|
-
term: conditionValue,
|
|
95
|
-
});
|
|
96
|
-
mConditions.push(_queryConditions);
|
|
97
|
-
}
|
|
98
|
-
else if (_conditionKey01 === "$between") {
|
|
99
|
-
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
100
|
-
const _queryConditions = this.operation__filterBetween({
|
|
101
|
-
fieldName: fieldName,
|
|
102
|
-
from: conditionValue[0],
|
|
103
|
-
to: conditionValue[1],
|
|
104
|
-
});
|
|
105
|
-
mConditions.push(_queryConditions);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
const conditionExpr = keyConditionMap[conditionKey];
|
|
109
|
-
if (conditionExpr) {
|
|
110
|
-
const _queryConditions = this.operation__helperFilterBasic({
|
|
111
|
-
fieldName: fieldName,
|
|
112
|
-
val: conditionValue,
|
|
113
|
-
conditionExpr: conditionExpr,
|
|
114
|
-
});
|
|
115
|
-
mConditions.push(_queryConditions);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
query_validator_1.QueryValidatorCheck.throwQueryNotFound(conditionKey);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
if (mConditions.length) {
|
|
124
|
-
let selectorValuesAll = {};
|
|
125
|
-
mConditions.forEach((condition) => {
|
|
126
|
-
selectorValuesAll = { ...selectorValuesAll, ...condition[fieldName] };
|
|
127
|
-
});
|
|
128
|
-
const result = {
|
|
129
|
-
[fieldName]: { $not: selectorValuesAll },
|
|
130
|
-
};
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
operation__filterContains({ fieldName, term }) {
|
|
136
|
-
const result = {
|
|
137
|
-
[fieldName]: { $regex: new RegExp(`${term}`, "ig") },
|
|
138
|
-
};
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
operation__filterNotContains({ fieldName, term }) {
|
|
142
|
-
const result = {
|
|
143
|
-
[fieldName]: { $not: { $regex: new RegExp(`${term}`, "ig") } },
|
|
144
|
-
};
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
operation__filterBetween({ fieldName, from, to, }) {
|
|
148
|
-
const result = {
|
|
149
|
-
[fieldName]: { $gte: from, $lte: to },
|
|
150
|
-
};
|
|
151
|
-
return result;
|
|
152
|
-
}
|
|
153
|
-
operation__filterBeginsWith({ fieldName, term }) {
|
|
154
|
-
const result = {
|
|
155
|
-
[fieldName]: { $regex: new RegExp(`^${term}`, "i") },
|
|
156
|
-
};
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
operation__filterNestedMatchObject({ fieldName, attrValues, }) {
|
|
160
|
-
const results = [];
|
|
161
|
-
Object.entries(attrValues).forEach(([subFieldName, queryval]) => {
|
|
162
|
-
let _queryValue;
|
|
163
|
-
if (queryval && typeof queryval === "object") {
|
|
164
|
-
_queryValue = { ...queryval };
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
_queryValue = { $eq: queryval };
|
|
168
|
-
}
|
|
169
|
-
Object.entries(_queryValue).forEach(([condKey, conditionValue]) => {
|
|
170
|
-
const conditionKey = condKey;
|
|
171
|
-
if (!Object.keys(keyConditionMap).includes(conditionKey)) {
|
|
172
|
-
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Invalid query key: ${conditionKey} @ NestedMatchObject`);
|
|
173
|
-
}
|
|
174
|
-
const conditionExpr = keyConditionMap[conditionKey];
|
|
175
|
-
if (conditionExpr) {
|
|
176
|
-
const result = {
|
|
177
|
-
[`${fieldName}.${subFieldName}`]: { [conditionExpr]: conditionValue },
|
|
178
|
-
};
|
|
179
|
-
results.push(result);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
if (conditionKey === "$between") {
|
|
183
|
-
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
184
|
-
const [fromVal, toVal] = conditionValue;
|
|
185
|
-
const result = {
|
|
186
|
-
[`${fieldName}.${subFieldName}`]: { $gte: fromVal, $lte: toVal },
|
|
187
|
-
};
|
|
188
|
-
results.push(result);
|
|
189
|
-
}
|
|
190
|
-
else if (conditionKey === "$beginsWith") {
|
|
191
|
-
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
192
|
-
const result = {
|
|
193
|
-
[`${fieldName}.${subFieldName}`]: { $regex: new RegExp(`^${conditionValue}`, "i") },
|
|
194
|
-
};
|
|
195
|
-
results.push(result);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Query key: ${conditionKey} not currently supported`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
return results;
|
|
204
|
-
}
|
|
205
|
-
operation__translateAdvancedQueryOperation({ fieldName, queryObject, }) {
|
|
206
|
-
const queryConditions = [];
|
|
207
|
-
Object.entries(queryObject).forEach(([condKey, conditionValue]) => {
|
|
208
|
-
const conditionKey = condKey;
|
|
209
|
-
if (conditionValue !== undefined) {
|
|
210
|
-
if (conditionKey === "$between") {
|
|
211
|
-
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
212
|
-
const _queryConditions = this.operation__filterBetween({
|
|
213
|
-
fieldName: fieldName,
|
|
214
|
-
from: conditionValue[0],
|
|
215
|
-
to: conditionValue[1],
|
|
216
|
-
});
|
|
217
|
-
queryConditions.push(_queryConditions);
|
|
218
|
-
}
|
|
219
|
-
else if (conditionKey === "$beginsWith") {
|
|
220
|
-
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
221
|
-
const _queryConditions = this.operation__filterBeginsWith({
|
|
222
|
-
fieldName: fieldName,
|
|
223
|
-
term: conditionValue,
|
|
224
|
-
});
|
|
225
|
-
queryConditions.push(_queryConditions);
|
|
226
|
-
}
|
|
227
|
-
else if (conditionKey === "$contains") {
|
|
228
|
-
query_validator_1.QueryValidatorCheck.contains(conditionValue);
|
|
229
|
-
const _queryConditions = this.operation__filterContains({
|
|
230
|
-
fieldName: fieldName,
|
|
231
|
-
term: conditionValue,
|
|
232
|
-
});
|
|
233
|
-
queryConditions.push(_queryConditions);
|
|
234
|
-
}
|
|
235
|
-
else if (conditionKey === "$notContains") {
|
|
236
|
-
query_validator_1.QueryValidatorCheck.notContains(conditionValue);
|
|
237
|
-
const _queryConditions = this.operation__filterNotContains({
|
|
238
|
-
fieldName: fieldName,
|
|
239
|
-
term: conditionValue,
|
|
240
|
-
});
|
|
241
|
-
queryConditions.push(_queryConditions);
|
|
242
|
-
}
|
|
243
|
-
else if (conditionKey === "$in") {
|
|
244
|
-
query_validator_1.QueryValidatorCheck.in_query(conditionValue);
|
|
245
|
-
const _queryConditions = this.operation__filterIn({
|
|
246
|
-
fieldName: fieldName,
|
|
247
|
-
attrValues: conditionValue,
|
|
248
|
-
});
|
|
249
|
-
queryConditions.push(_queryConditions);
|
|
250
|
-
}
|
|
251
|
-
else if (conditionKey === "$nin") {
|
|
252
|
-
query_validator_1.QueryValidatorCheck.notIn(conditionValue);
|
|
253
|
-
const _queryConditions = this.operation__filterNotIn({
|
|
254
|
-
fieldName: fieldName,
|
|
255
|
-
attrValues: conditionValue,
|
|
256
|
-
});
|
|
257
|
-
queryConditions.push(_queryConditions);
|
|
258
|
-
}
|
|
259
|
-
else if (conditionKey === "$elemMatch") {
|
|
260
|
-
query_validator_1.QueryValidatorCheck.elemMatch(conditionValue);
|
|
261
|
-
const _queryConditions = this.operation__filterElementMatch({
|
|
262
|
-
fieldName: fieldName,
|
|
263
|
-
attrValues: conditionValue,
|
|
264
|
-
});
|
|
265
|
-
queryConditions.push(_queryConditions);
|
|
266
|
-
}
|
|
267
|
-
else if (conditionKey === "$nestedMatch") {
|
|
268
|
-
query_validator_1.QueryValidatorCheck.nestedMatch(conditionValue);
|
|
269
|
-
const nestedMatchConditions = this.operation__filterNestedMatchObject({
|
|
270
|
-
fieldName: fieldName,
|
|
271
|
-
attrValues: conditionValue,
|
|
272
|
-
});
|
|
273
|
-
if (nestedMatchConditions?.length) {
|
|
274
|
-
nestedMatchConditions.forEach((cond) => {
|
|
275
|
-
queryConditions.push(cond);
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
else if (conditionKey === "$not") {
|
|
280
|
-
query_validator_1.QueryValidatorCheck.not_query(conditionValue);
|
|
281
|
-
const _queryConditions = this.operation__filterNot({
|
|
282
|
-
fieldName: fieldName,
|
|
283
|
-
selectorObjValues: conditionValue,
|
|
284
|
-
});
|
|
285
|
-
if (_queryConditions) {
|
|
286
|
-
queryConditions.push(_queryConditions);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else if (conditionKey === "$exists") {
|
|
290
|
-
query_validator_1.QueryValidatorCheck.exists(conditionValue);
|
|
291
|
-
if (String(conditionValue) === "true") {
|
|
292
|
-
const _queryConditions = this.operation__filterFieldExist({
|
|
293
|
-
fieldName: fieldName,
|
|
294
|
-
});
|
|
295
|
-
queryConditions.push(_queryConditions);
|
|
296
|
-
}
|
|
297
|
-
else if (String(conditionValue) === "false") {
|
|
298
|
-
const _queryConditions = this.operation__filterFieldNotExist({
|
|
299
|
-
fieldName: fieldName,
|
|
300
|
-
});
|
|
301
|
-
queryConditions.push(_queryConditions);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
const conditionExpr = getQueryConditionExpression(conditionKey);
|
|
306
|
-
if (conditionExpr) {
|
|
307
|
-
const _queryConditions = this.operation__helperFilterBasic({
|
|
308
|
-
fieldName: fieldName,
|
|
309
|
-
val: conditionValue,
|
|
310
|
-
conditionExpr: conditionExpr,
|
|
311
|
-
});
|
|
312
|
-
queryConditions.push(_queryConditions);
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
query_validator_1.QueryValidatorCheck.throwQueryNotFound(conditionKey);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
return queryConditions;
|
|
321
|
-
}
|
|
322
|
-
operation_translateBasicQueryOperation({ fieldName, queryObject }) {
|
|
323
|
-
const _queryConditions = this.operation__helperFilterBasic({
|
|
324
|
-
fieldName: fieldName,
|
|
325
|
-
val: queryObject,
|
|
326
|
-
});
|
|
327
|
-
return _queryConditions;
|
|
328
|
-
}
|
|
329
|
-
processQueryFilter({ queryDefs }) {
|
|
330
|
-
let queryMainConditions = [];
|
|
331
|
-
let queryAndConditions = [];
|
|
332
|
-
const queryOrConditions = [];
|
|
333
|
-
Object.entries(queryDefs).forEach(([conditionKey, conditionValue]) => {
|
|
334
|
-
if (conditionKey === "$or") {
|
|
335
|
-
const orArray = conditionValue;
|
|
336
|
-
query_validator_1.QueryValidatorCheck.or_query(orArray);
|
|
337
|
-
orArray.forEach((orQuery) => {
|
|
338
|
-
const perQueryCondition02 = {};
|
|
339
|
-
Object.entries(orQuery).forEach(([fieldName, orQueryObjectOrValue]) => {
|
|
340
|
-
if (orQueryObjectOrValue !== undefined) {
|
|
341
|
-
if (orQueryObjectOrValue && typeof orQueryObjectOrValue === "object") {
|
|
342
|
-
const orQueryCond01 = this.operation__translateAdvancedQueryOperation({
|
|
343
|
-
fieldName,
|
|
344
|
-
queryObject: orQueryObjectOrValue,
|
|
345
|
-
});
|
|
346
|
-
let nquery = {};
|
|
347
|
-
for (const xcond of orQueryCond01) {
|
|
348
|
-
Object.entries(xcond).forEach(([_, value]) => {
|
|
349
|
-
nquery = { ...nquery, ...value };
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
perQueryCondition02[fieldName] = nquery;
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
const orQueryCondition02 = this.operation_translateBasicQueryOperation({
|
|
356
|
-
fieldName,
|
|
357
|
-
queryObject: orQueryObjectOrValue,
|
|
358
|
-
});
|
|
359
|
-
let nquery02 = {};
|
|
360
|
-
Object.entries(orQueryCondition02).forEach(([_, value]) => {
|
|
361
|
-
nquery02 = { ...nquery02, ...value };
|
|
362
|
-
});
|
|
363
|
-
perQueryCondition02[fieldName] = nquery02;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
if (Object.keys(perQueryCondition02).length) {
|
|
368
|
-
queryOrConditions.push(perQueryCondition02);
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
else if (conditionKey === "$and") {
|
|
373
|
-
const andArray = conditionValue;
|
|
374
|
-
query_validator_1.QueryValidatorCheck.and_query(conditionValue);
|
|
375
|
-
andArray.forEach((andQuery) => {
|
|
376
|
-
Object.entries(andQuery).forEach(([fieldName, andQueryObjectOrValue]) => {
|
|
377
|
-
if (andQueryObjectOrValue !== undefined) {
|
|
378
|
-
if (andQueryObjectOrValue && typeof andQueryObjectOrValue === "object") {
|
|
379
|
-
const _andQueryCond = this.operation__translateAdvancedQueryOperation({
|
|
380
|
-
fieldName,
|
|
381
|
-
queryObject: andQueryObjectOrValue,
|
|
382
|
-
});
|
|
383
|
-
queryAndConditions = [...queryAndConditions, ..._andQueryCond];
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
const _andQueryConditions = this.operation_translateBasicQueryOperation({
|
|
387
|
-
fieldName,
|
|
388
|
-
queryObject: andQueryObjectOrValue,
|
|
389
|
-
});
|
|
390
|
-
queryAndConditions = [...queryAndConditions, _andQueryConditions];
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
if (conditionKey && conditionValue !== undefined) {
|
|
398
|
-
if (conditionValue && typeof conditionValue === "object") {
|
|
399
|
-
const _queryCond = this.operation__translateAdvancedQueryOperation({
|
|
400
|
-
fieldName: conditionKey,
|
|
401
|
-
queryObject: conditionValue,
|
|
402
|
-
});
|
|
403
|
-
queryMainConditions = [...queryMainConditions, ..._queryCond];
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
const _queryConditions = this.operation_translateBasicQueryOperation({
|
|
407
|
-
fieldName: conditionKey,
|
|
408
|
-
queryObject: conditionValue,
|
|
409
|
-
});
|
|
410
|
-
queryMainConditions = [...queryMainConditions, _queryConditions];
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
let queryAllConditions = {};
|
|
416
|
-
if (queryMainConditions?.length) {
|
|
417
|
-
queryMainConditions.forEach((item1) => {
|
|
418
|
-
if (item1) {
|
|
419
|
-
queryAllConditions = { ...queryAllConditions, ...item1 };
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
if (queryAndConditions?.length) {
|
|
424
|
-
queryAllConditions.$and = queryAndConditions;
|
|
425
|
-
}
|
|
426
|
-
if (queryOrConditions?.length) {
|
|
427
|
-
queryAllConditions.$or = queryOrConditions;
|
|
428
|
-
}
|
|
429
|
-
logging_service_1.LoggingService.log(JSON.stringify({ queryAllConditions }, null, 2));
|
|
430
|
-
return queryAllConditions;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
exports.MongoFilterQueryOperation = MongoFilterQueryOperation;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoFilterQueryOperation = void 0;
|
|
4
|
+
const logging_service_1 = require("./../helpers/logging-service");
|
|
5
|
+
const query_validator_1 = require("../helpers/query-validator");
|
|
6
|
+
const errors_1 = require("../helpers/errors");
|
|
7
|
+
const keyConditionMap = {
|
|
8
|
+
$eq: "$eq",
|
|
9
|
+
$lt: "$lt",
|
|
10
|
+
$lte: "$lte",
|
|
11
|
+
$gt: "$gt",
|
|
12
|
+
$gte: "$gte",
|
|
13
|
+
$between: "",
|
|
14
|
+
$beginsWith: "",
|
|
15
|
+
};
|
|
16
|
+
const conditionMapPre = {
|
|
17
|
+
$ne: "$ne",
|
|
18
|
+
$exists: "",
|
|
19
|
+
$in: "",
|
|
20
|
+
$nin: "",
|
|
21
|
+
$not: "",
|
|
22
|
+
$contains: "",
|
|
23
|
+
$notContains: "",
|
|
24
|
+
$elemMatch: "",
|
|
25
|
+
$nestedMatch: "",
|
|
26
|
+
};
|
|
27
|
+
const conditionMap = { ...keyConditionMap, ...conditionMapPre };
|
|
28
|
+
function hasQueryKeyCondition(key) {
|
|
29
|
+
return Object.keys(keyConditionMap).includes(key);
|
|
30
|
+
}
|
|
31
|
+
function getQueryConditionExpression(key) {
|
|
32
|
+
if (key && Object.keys(conditionMap).includes(key)) {
|
|
33
|
+
const conditionExpr = conditionMap[key];
|
|
34
|
+
if (conditionExpr) {
|
|
35
|
+
return conditionExpr;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
class MongoFilterQueryOperation {
|
|
41
|
+
operation__filterFieldExist({ fieldName }) {
|
|
42
|
+
const result = {
|
|
43
|
+
[fieldName]: { $exists: true },
|
|
44
|
+
};
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
operation__filterFieldNotExist({ fieldName }) {
|
|
48
|
+
const result = {
|
|
49
|
+
[fieldName]: { $exists: false },
|
|
50
|
+
};
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
operation__helperFilterBasic({ fieldName, val, conditionExpr, }) {
|
|
54
|
+
if (conditionExpr) {
|
|
55
|
+
return {
|
|
56
|
+
[fieldName]: { [conditionExpr]: val },
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const result = {
|
|
60
|
+
[fieldName]: { $eq: val },
|
|
61
|
+
};
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
operation__filterIn({ fieldName, attrValues }) {
|
|
65
|
+
const result = {
|
|
66
|
+
[fieldName]: { $in: attrValues },
|
|
67
|
+
};
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
operation__filterElementMatch({ fieldName, attrValues, }) {
|
|
71
|
+
const result = {
|
|
72
|
+
[fieldName]: {
|
|
73
|
+
$elemMatch: attrValues,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
operation__filterNotIn({ fieldName, attrValues, }) {
|
|
79
|
+
const result = {
|
|
80
|
+
[fieldName]: { $nin: attrValues },
|
|
81
|
+
};
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
operation__filterNot({ fieldName, selectorObjValues, }) {
|
|
85
|
+
const selector = { ...selectorObjValues };
|
|
86
|
+
const mConditions = [];
|
|
87
|
+
Object.entries(selector).forEach(([conditionKey, conditionValue]) => {
|
|
88
|
+
if (hasQueryKeyCondition(conditionKey)) {
|
|
89
|
+
const _conditionKey01 = conditionKey;
|
|
90
|
+
if (_conditionKey01 === "$beginsWith") {
|
|
91
|
+
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
92
|
+
const _queryConditions = this.operation__filterBeginsWith({
|
|
93
|
+
fieldName: fieldName,
|
|
94
|
+
term: conditionValue,
|
|
95
|
+
});
|
|
96
|
+
mConditions.push(_queryConditions);
|
|
97
|
+
}
|
|
98
|
+
else if (_conditionKey01 === "$between") {
|
|
99
|
+
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
100
|
+
const _queryConditions = this.operation__filterBetween({
|
|
101
|
+
fieldName: fieldName,
|
|
102
|
+
from: conditionValue[0],
|
|
103
|
+
to: conditionValue[1],
|
|
104
|
+
});
|
|
105
|
+
mConditions.push(_queryConditions);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const conditionExpr = keyConditionMap[conditionKey];
|
|
109
|
+
if (conditionExpr) {
|
|
110
|
+
const _queryConditions = this.operation__helperFilterBasic({
|
|
111
|
+
fieldName: fieldName,
|
|
112
|
+
val: conditionValue,
|
|
113
|
+
conditionExpr: conditionExpr,
|
|
114
|
+
});
|
|
115
|
+
mConditions.push(_queryConditions);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
query_validator_1.QueryValidatorCheck.throwQueryNotFound(conditionKey);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
if (mConditions.length) {
|
|
124
|
+
let selectorValuesAll = {};
|
|
125
|
+
mConditions.forEach((condition) => {
|
|
126
|
+
selectorValuesAll = { ...selectorValuesAll, ...condition[fieldName] };
|
|
127
|
+
});
|
|
128
|
+
const result = {
|
|
129
|
+
[fieldName]: { $not: selectorValuesAll },
|
|
130
|
+
};
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
operation__filterContains({ fieldName, term }) {
|
|
136
|
+
const result = {
|
|
137
|
+
[fieldName]: { $regex: new RegExp(`${term}`, "ig") },
|
|
138
|
+
};
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
operation__filterNotContains({ fieldName, term }) {
|
|
142
|
+
const result = {
|
|
143
|
+
[fieldName]: { $not: { $regex: new RegExp(`${term}`, "ig") } },
|
|
144
|
+
};
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
operation__filterBetween({ fieldName, from, to, }) {
|
|
148
|
+
const result = {
|
|
149
|
+
[fieldName]: { $gte: from, $lte: to },
|
|
150
|
+
};
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
operation__filterBeginsWith({ fieldName, term }) {
|
|
154
|
+
const result = {
|
|
155
|
+
[fieldName]: { $regex: new RegExp(`^${term}`, "i") },
|
|
156
|
+
};
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
operation__filterNestedMatchObject({ fieldName, attrValues, }) {
|
|
160
|
+
const results = [];
|
|
161
|
+
Object.entries(attrValues).forEach(([subFieldName, queryval]) => {
|
|
162
|
+
let _queryValue;
|
|
163
|
+
if (queryval && typeof queryval === "object") {
|
|
164
|
+
_queryValue = { ...queryval };
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
_queryValue = { $eq: queryval };
|
|
168
|
+
}
|
|
169
|
+
Object.entries(_queryValue).forEach(([condKey, conditionValue]) => {
|
|
170
|
+
const conditionKey = condKey;
|
|
171
|
+
if (!Object.keys(keyConditionMap).includes(conditionKey)) {
|
|
172
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Invalid query key: ${conditionKey} @ NestedMatchObject`);
|
|
173
|
+
}
|
|
174
|
+
const conditionExpr = keyConditionMap[conditionKey];
|
|
175
|
+
if (conditionExpr) {
|
|
176
|
+
const result = {
|
|
177
|
+
[`${fieldName}.${subFieldName}`]: { [conditionExpr]: conditionValue },
|
|
178
|
+
};
|
|
179
|
+
results.push(result);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
if (conditionKey === "$between") {
|
|
183
|
+
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
184
|
+
const [fromVal, toVal] = conditionValue;
|
|
185
|
+
const result = {
|
|
186
|
+
[`${fieldName}.${subFieldName}`]: { $gte: fromVal, $lte: toVal },
|
|
187
|
+
};
|
|
188
|
+
results.push(result);
|
|
189
|
+
}
|
|
190
|
+
else if (conditionKey === "$beginsWith") {
|
|
191
|
+
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
192
|
+
const result = {
|
|
193
|
+
[`${fieldName}.${subFieldName}`]: { $regex: new RegExp(`^${conditionValue}`, "i") },
|
|
194
|
+
};
|
|
195
|
+
results.push(result);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Query key: ${conditionKey} not currently supported`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
return results;
|
|
204
|
+
}
|
|
205
|
+
operation__translateAdvancedQueryOperation({ fieldName, queryObject, }) {
|
|
206
|
+
const queryConditions = [];
|
|
207
|
+
Object.entries(queryObject).forEach(([condKey, conditionValue]) => {
|
|
208
|
+
const conditionKey = condKey;
|
|
209
|
+
if (conditionValue !== undefined) {
|
|
210
|
+
if (conditionKey === "$between") {
|
|
211
|
+
query_validator_1.QueryValidatorCheck.between(conditionValue);
|
|
212
|
+
const _queryConditions = this.operation__filterBetween({
|
|
213
|
+
fieldName: fieldName,
|
|
214
|
+
from: conditionValue[0],
|
|
215
|
+
to: conditionValue[1],
|
|
216
|
+
});
|
|
217
|
+
queryConditions.push(_queryConditions);
|
|
218
|
+
}
|
|
219
|
+
else if (conditionKey === "$beginsWith") {
|
|
220
|
+
query_validator_1.QueryValidatorCheck.beginWith(conditionValue);
|
|
221
|
+
const _queryConditions = this.operation__filterBeginsWith({
|
|
222
|
+
fieldName: fieldName,
|
|
223
|
+
term: conditionValue,
|
|
224
|
+
});
|
|
225
|
+
queryConditions.push(_queryConditions);
|
|
226
|
+
}
|
|
227
|
+
else if (conditionKey === "$contains") {
|
|
228
|
+
query_validator_1.QueryValidatorCheck.contains(conditionValue);
|
|
229
|
+
const _queryConditions = this.operation__filterContains({
|
|
230
|
+
fieldName: fieldName,
|
|
231
|
+
term: conditionValue,
|
|
232
|
+
});
|
|
233
|
+
queryConditions.push(_queryConditions);
|
|
234
|
+
}
|
|
235
|
+
else if (conditionKey === "$notContains") {
|
|
236
|
+
query_validator_1.QueryValidatorCheck.notContains(conditionValue);
|
|
237
|
+
const _queryConditions = this.operation__filterNotContains({
|
|
238
|
+
fieldName: fieldName,
|
|
239
|
+
term: conditionValue,
|
|
240
|
+
});
|
|
241
|
+
queryConditions.push(_queryConditions);
|
|
242
|
+
}
|
|
243
|
+
else if (conditionKey === "$in") {
|
|
244
|
+
query_validator_1.QueryValidatorCheck.in_query(conditionValue);
|
|
245
|
+
const _queryConditions = this.operation__filterIn({
|
|
246
|
+
fieldName: fieldName,
|
|
247
|
+
attrValues: conditionValue,
|
|
248
|
+
});
|
|
249
|
+
queryConditions.push(_queryConditions);
|
|
250
|
+
}
|
|
251
|
+
else if (conditionKey === "$nin") {
|
|
252
|
+
query_validator_1.QueryValidatorCheck.notIn(conditionValue);
|
|
253
|
+
const _queryConditions = this.operation__filterNotIn({
|
|
254
|
+
fieldName: fieldName,
|
|
255
|
+
attrValues: conditionValue,
|
|
256
|
+
});
|
|
257
|
+
queryConditions.push(_queryConditions);
|
|
258
|
+
}
|
|
259
|
+
else if (conditionKey === "$elemMatch") {
|
|
260
|
+
query_validator_1.QueryValidatorCheck.elemMatch(conditionValue);
|
|
261
|
+
const _queryConditions = this.operation__filterElementMatch({
|
|
262
|
+
fieldName: fieldName,
|
|
263
|
+
attrValues: conditionValue,
|
|
264
|
+
});
|
|
265
|
+
queryConditions.push(_queryConditions);
|
|
266
|
+
}
|
|
267
|
+
else if (conditionKey === "$nestedMatch") {
|
|
268
|
+
query_validator_1.QueryValidatorCheck.nestedMatch(conditionValue);
|
|
269
|
+
const nestedMatchConditions = this.operation__filterNestedMatchObject({
|
|
270
|
+
fieldName: fieldName,
|
|
271
|
+
attrValues: conditionValue,
|
|
272
|
+
});
|
|
273
|
+
if (nestedMatchConditions?.length) {
|
|
274
|
+
nestedMatchConditions.forEach((cond) => {
|
|
275
|
+
queryConditions.push(cond);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
else if (conditionKey === "$not") {
|
|
280
|
+
query_validator_1.QueryValidatorCheck.not_query(conditionValue);
|
|
281
|
+
const _queryConditions = this.operation__filterNot({
|
|
282
|
+
fieldName: fieldName,
|
|
283
|
+
selectorObjValues: conditionValue,
|
|
284
|
+
});
|
|
285
|
+
if (_queryConditions) {
|
|
286
|
+
queryConditions.push(_queryConditions);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else if (conditionKey === "$exists") {
|
|
290
|
+
query_validator_1.QueryValidatorCheck.exists(conditionValue);
|
|
291
|
+
if (String(conditionValue) === "true") {
|
|
292
|
+
const _queryConditions = this.operation__filterFieldExist({
|
|
293
|
+
fieldName: fieldName,
|
|
294
|
+
});
|
|
295
|
+
queryConditions.push(_queryConditions);
|
|
296
|
+
}
|
|
297
|
+
else if (String(conditionValue) === "false") {
|
|
298
|
+
const _queryConditions = this.operation__filterFieldNotExist({
|
|
299
|
+
fieldName: fieldName,
|
|
300
|
+
});
|
|
301
|
+
queryConditions.push(_queryConditions);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
const conditionExpr = getQueryConditionExpression(conditionKey);
|
|
306
|
+
if (conditionExpr) {
|
|
307
|
+
const _queryConditions = this.operation__helperFilterBasic({
|
|
308
|
+
fieldName: fieldName,
|
|
309
|
+
val: conditionValue,
|
|
310
|
+
conditionExpr: conditionExpr,
|
|
311
|
+
});
|
|
312
|
+
queryConditions.push(_queryConditions);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
query_validator_1.QueryValidatorCheck.throwQueryNotFound(conditionKey);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
return queryConditions;
|
|
321
|
+
}
|
|
322
|
+
operation_translateBasicQueryOperation({ fieldName, queryObject }) {
|
|
323
|
+
const _queryConditions = this.operation__helperFilterBasic({
|
|
324
|
+
fieldName: fieldName,
|
|
325
|
+
val: queryObject,
|
|
326
|
+
});
|
|
327
|
+
return _queryConditions;
|
|
328
|
+
}
|
|
329
|
+
processQueryFilter({ queryDefs }) {
|
|
330
|
+
let queryMainConditions = [];
|
|
331
|
+
let queryAndConditions = [];
|
|
332
|
+
const queryOrConditions = [];
|
|
333
|
+
Object.entries(queryDefs).forEach(([conditionKey, conditionValue]) => {
|
|
334
|
+
if (conditionKey === "$or") {
|
|
335
|
+
const orArray = conditionValue;
|
|
336
|
+
query_validator_1.QueryValidatorCheck.or_query(orArray);
|
|
337
|
+
orArray.forEach((orQuery) => {
|
|
338
|
+
const perQueryCondition02 = {};
|
|
339
|
+
Object.entries(orQuery).forEach(([fieldName, orQueryObjectOrValue]) => {
|
|
340
|
+
if (orQueryObjectOrValue !== undefined) {
|
|
341
|
+
if (orQueryObjectOrValue && typeof orQueryObjectOrValue === "object") {
|
|
342
|
+
const orQueryCond01 = this.operation__translateAdvancedQueryOperation({
|
|
343
|
+
fieldName,
|
|
344
|
+
queryObject: orQueryObjectOrValue,
|
|
345
|
+
});
|
|
346
|
+
let nquery = {};
|
|
347
|
+
for (const xcond of orQueryCond01) {
|
|
348
|
+
Object.entries(xcond).forEach(([_, value]) => {
|
|
349
|
+
nquery = { ...nquery, ...value };
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
perQueryCondition02[fieldName] = nquery;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
const orQueryCondition02 = this.operation_translateBasicQueryOperation({
|
|
356
|
+
fieldName,
|
|
357
|
+
queryObject: orQueryObjectOrValue,
|
|
358
|
+
});
|
|
359
|
+
let nquery02 = {};
|
|
360
|
+
Object.entries(orQueryCondition02).forEach(([_, value]) => {
|
|
361
|
+
nquery02 = { ...nquery02, ...value };
|
|
362
|
+
});
|
|
363
|
+
perQueryCondition02[fieldName] = nquery02;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
if (Object.keys(perQueryCondition02).length) {
|
|
368
|
+
queryOrConditions.push(perQueryCondition02);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
else if (conditionKey === "$and") {
|
|
373
|
+
const andArray = conditionValue;
|
|
374
|
+
query_validator_1.QueryValidatorCheck.and_query(conditionValue);
|
|
375
|
+
andArray.forEach((andQuery) => {
|
|
376
|
+
Object.entries(andQuery).forEach(([fieldName, andQueryObjectOrValue]) => {
|
|
377
|
+
if (andQueryObjectOrValue !== undefined) {
|
|
378
|
+
if (andQueryObjectOrValue && typeof andQueryObjectOrValue === "object") {
|
|
379
|
+
const _andQueryCond = this.operation__translateAdvancedQueryOperation({
|
|
380
|
+
fieldName,
|
|
381
|
+
queryObject: andQueryObjectOrValue,
|
|
382
|
+
});
|
|
383
|
+
queryAndConditions = [...queryAndConditions, ..._andQueryCond];
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
const _andQueryConditions = this.operation_translateBasicQueryOperation({
|
|
387
|
+
fieldName,
|
|
388
|
+
queryObject: andQueryObjectOrValue,
|
|
389
|
+
});
|
|
390
|
+
queryAndConditions = [...queryAndConditions, _andQueryConditions];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
if (conditionKey && conditionValue !== undefined) {
|
|
398
|
+
if (conditionValue && typeof conditionValue === "object") {
|
|
399
|
+
const _queryCond = this.operation__translateAdvancedQueryOperation({
|
|
400
|
+
fieldName: conditionKey,
|
|
401
|
+
queryObject: conditionValue,
|
|
402
|
+
});
|
|
403
|
+
queryMainConditions = [...queryMainConditions, ..._queryCond];
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
const _queryConditions = this.operation_translateBasicQueryOperation({
|
|
407
|
+
fieldName: conditionKey,
|
|
408
|
+
queryObject: conditionValue,
|
|
409
|
+
});
|
|
410
|
+
queryMainConditions = [...queryMainConditions, _queryConditions];
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
let queryAllConditions = {};
|
|
416
|
+
if (queryMainConditions?.length) {
|
|
417
|
+
queryMainConditions.forEach((item1) => {
|
|
418
|
+
if (item1) {
|
|
419
|
+
queryAllConditions = { ...queryAllConditions, ...item1 };
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
if (queryAndConditions?.length) {
|
|
424
|
+
queryAllConditions.$and = queryAndConditions;
|
|
425
|
+
}
|
|
426
|
+
if (queryOrConditions?.length) {
|
|
427
|
+
queryAllConditions.$or = queryOrConditions;
|
|
428
|
+
}
|
|
429
|
+
logging_service_1.LoggingService.log(JSON.stringify({ queryAllConditions }, null, 2));
|
|
430
|
+
return queryAllConditions;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
exports.MongoFilterQueryOperation = MongoFilterQueryOperation;
|
|
434
434
|
//# sourceMappingURL=mongo-filter-query-operation.js.map
|