@xuda.io/xuda-dbs-plugin-xuda 1.0.189 → 1.0.191
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/server.js +197 -185
- package/studio.mjs +246 -196
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@xuda.io/xuda-dbs-plugin-xuda",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.191",
|
4
4
|
"description": "Xuda Database Socket for Xuda's proprietary structure powered by CouchDB",
|
5
5
|
"scripts": {
|
6
6
|
"pub": "npm version patch --force && npm publish --access public"
|
package/server.js
CHANGED
@@ -254,7 +254,19 @@ const get_opt = function (e, table_obj) {
|
|
254
254
|
opt.sort = sort;
|
255
255
|
}
|
256
256
|
|
257
|
-
if (e?.sortModel?.length) {
|
257
|
+
// if (e?.sortModel?.length) {
|
258
|
+
// opt.sort = JSON.parse(e.sortModel);
|
259
|
+
// if (opt.sort) {
|
260
|
+
// for (const [key, val] of Object.entries(opt.sort)) {
|
261
|
+
// var field_name = val.colId;
|
262
|
+
// opt.sort[key] = {
|
263
|
+
// ["udfData.data." + field_name]: val.sort,
|
264
|
+
// };
|
265
|
+
// }
|
266
|
+
// }
|
267
|
+
// }
|
268
|
+
|
269
|
+
if (e?.sortModel && JSON.parse(e.sortModel).length) {
|
258
270
|
opt.sort = JSON.parse(e.sortModel);
|
259
271
|
if (opt.sort) {
|
260
272
|
for (const [key, val] of Object.entries(opt.sort)) {
|
@@ -266,190 +278,190 @@ const get_opt = function (e, table_obj) {
|
|
266
278
|
}
|
267
279
|
}
|
268
280
|
|
269
|
-
if (e.filterModel) {
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
}
|
281
|
+
// if (e.filterModel) {
|
282
|
+
// debugger;
|
283
|
+
// for (const [key, val] of Object.entries(e.filterModel)) {
|
284
|
+
// var field_name = key;
|
285
|
+
// var condition = "$and";
|
286
|
+
// const make_selector = function (val) {
|
287
|
+
// var value = "";
|
288
|
+
// var operator = "";
|
289
|
+
// var value_to = "";
|
290
|
+
// var operator_to = "";
|
291
|
+
|
292
|
+
// if (val.filterType === "date") {
|
293
|
+
// var date = val.dateFrom.substr(0, 10);
|
294
|
+
// switch (val.type) {
|
295
|
+
// case "equals":
|
296
|
+
// operator = "$regex";
|
297
|
+
// value = `^${date}`;
|
298
|
+
// break;
|
299
|
+
|
300
|
+
// case "greaterThan":
|
301
|
+
// operator = "$gt";
|
302
|
+
// value = `${date}`;
|
303
|
+
// break;
|
304
|
+
|
305
|
+
// case "lessThan":
|
306
|
+
// operator = "$lt";
|
307
|
+
// value = `${date}`;
|
308
|
+
// break;
|
309
|
+
|
310
|
+
// case "blank":
|
311
|
+
// operator = "$eq";
|
312
|
+
// value = "";
|
313
|
+
// break;
|
314
|
+
|
315
|
+
// case "inRange":
|
316
|
+
// operator = "$gte";
|
317
|
+
// value = date;
|
318
|
+
// operator_to = "$lte";
|
319
|
+
// value_to = val.dateTo.substr(0, 10);
|
320
|
+
// break;
|
321
|
+
|
322
|
+
// case "notEqual":
|
323
|
+
// operator = "$regex";
|
324
|
+
// value = `^((?!${date}).)*$`;
|
325
|
+
// break;
|
326
|
+
|
327
|
+
// case "notBlank":
|
328
|
+
// operator = "$ne";
|
329
|
+
// value = "";
|
330
|
+
// break;
|
331
|
+
|
332
|
+
// default:
|
333
|
+
// operator = "$regex";
|
334
|
+
// value = `^${date}`;
|
335
|
+
// }
|
336
|
+
// }
|
337
|
+
|
338
|
+
// if (val.filterType === "string" || val.filterType === "text") {
|
339
|
+
// switch (val.type) {
|
340
|
+
// case "contains":
|
341
|
+
// operator = "$regex";
|
342
|
+
// value = `${val.filter}`;
|
343
|
+
// break;
|
344
|
+
|
345
|
+
// case "notContains":
|
346
|
+
// operator = "$regex";
|
347
|
+
// value = `^((?!${val.filter}).)*$`;
|
348
|
+
// break;
|
349
|
+
|
350
|
+
// case "equals":
|
351
|
+
// operator = "$eq";
|
352
|
+
// value = `${val.filter}`;
|
353
|
+
// break;
|
354
|
+
|
355
|
+
// case "notEqual":
|
356
|
+
// operator = "$ne";
|
357
|
+
// value = `${val.filter}`;
|
358
|
+
// break;
|
359
|
+
|
360
|
+
// case "startsWith":
|
361
|
+
// operator = "$regex";
|
362
|
+
// value = `^${val.filter}`;
|
363
|
+
// break;
|
364
|
+
|
365
|
+
// case "endsWith":
|
366
|
+
// operator = "$regex";
|
367
|
+
// value = `${val.filter}$`;
|
368
|
+
// break;
|
369
|
+
|
370
|
+
// case "blank":
|
371
|
+
// operator = "$eq";
|
372
|
+
// value = "";
|
373
|
+
// break;
|
374
|
+
|
375
|
+
// case "notBlank":
|
376
|
+
// operator = "$ne";
|
377
|
+
// value = "";
|
378
|
+
// break;
|
379
|
+
|
380
|
+
// default:
|
381
|
+
// value = "^" + val.filter;
|
382
|
+
// }
|
383
|
+
// }
|
384
|
+
|
385
|
+
// if (val.filterType === "number") {
|
386
|
+
// switch (val.type) {
|
387
|
+
// case "equals":
|
388
|
+
// operator = "$eq";
|
389
|
+
// value = val.filter;
|
390
|
+
// break;
|
391
|
+
|
392
|
+
// case "notEqual":
|
393
|
+
// operator = "$ne";
|
394
|
+
// value = val.filter;
|
395
|
+
// break;
|
396
|
+
|
397
|
+
// case "lessThanOrEqual":
|
398
|
+
// operator = "$lte";
|
399
|
+
// value = val.filter;
|
400
|
+
// break;
|
401
|
+
|
402
|
+
// case "greaterThanOrEqual":
|
403
|
+
// operator = "$gte";
|
404
|
+
// value = val.filter;
|
405
|
+
// break;
|
406
|
+
|
407
|
+
// case "lessThan":
|
408
|
+
// operator = "$lt";
|
409
|
+
// value = val.filter;
|
410
|
+
// break;
|
411
|
+
|
412
|
+
// case "greaterThan":
|
413
|
+
// operator = "$gt";
|
414
|
+
// value = val.filter;
|
415
|
+
// break;
|
416
|
+
|
417
|
+
// case "blank":
|
418
|
+
// operator = "$eq";
|
419
|
+
// value = 0;
|
420
|
+
// break;
|
421
|
+
|
422
|
+
// case "notBlank":
|
423
|
+
// operator = "$ne";
|
424
|
+
// value = 0;
|
425
|
+
// break;
|
426
|
+
|
427
|
+
// case "inRange":
|
428
|
+
// operator = "$gte";
|
429
|
+
// value = val.filter;
|
430
|
+
// operator_to = "$lte";
|
431
|
+
// value_to = val.filterTo;
|
432
|
+
// break;
|
433
|
+
|
434
|
+
// default:
|
435
|
+
// operator = "$eq";
|
436
|
+
// value = val.filter;
|
437
|
+
// }
|
438
|
+
// }
|
439
|
+
// if (!opt.selector[field_name]) {
|
440
|
+
// opt.selector[field_name] = {};
|
441
|
+
// }
|
442
|
+
// if (!opt.selector[field_name][condition]) {
|
443
|
+
// opt.selector[field_name][condition] = [];
|
444
|
+
// }
|
445
|
+
// opt.selector[field_name][condition].push({
|
446
|
+
// [operator]: value,
|
447
|
+
// });
|
448
|
+
|
449
|
+
// if (operator_to) {
|
450
|
+
// opt.selector[field_name][condition].push({
|
451
|
+
// [operator_to]: value_to,
|
452
|
+
// });
|
453
|
+
// }
|
454
|
+
// };
|
455
|
+
|
456
|
+
// if (!val.condition1) {
|
457
|
+
// make_selector(val);
|
458
|
+
// } else {
|
459
|
+
// condition = "$" + val.operator.toLowerCase();
|
460
|
+
// make_selector(val.condition1);
|
461
|
+
// make_selector(val.condition2);
|
462
|
+
// }
|
463
|
+
// }
|
464
|
+
// }
|
453
465
|
|
454
466
|
if (e.total_fields_info) {
|
455
467
|
fields = [];
|
package/studio.mjs
CHANGED
@@ -295,191 +295,191 @@ const get_opt = function (e, table_obj) {
|
|
295
295
|
}
|
296
296
|
}
|
297
297
|
|
298
|
-
if (e.filterModel && JSON.parse(e.filterModel)) {
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
}
|
298
|
+
// if (e.filterModel && JSON.parse(e.filterModel)) {
|
299
|
+
// debugger;
|
300
|
+
// for (const [key, val] of Object.entries(JSON.parse(e.filterModel))) {
|
301
|
+
// var field_name = "udfData.data." + key;
|
302
|
+
// var condition = "$and";
|
303
|
+
// const make_selector = function (val) {
|
304
|
+
// var value = "";
|
305
|
+
// var operator = "";
|
306
|
+
// var value_to = "";
|
307
|
+
// var operator_to = "";
|
308
|
+
|
309
|
+
// if (val.filterType === "date") {
|
310
|
+
// var date = val.dateFrom.substr(0, 10);
|
311
|
+
// switch (val.type) {
|
312
|
+
// case "equals":
|
313
|
+
// operator = "$regex";
|
314
|
+
// value = `^${date}`;
|
315
|
+
// break;
|
316
|
+
|
317
|
+
// case "greaterThan":
|
318
|
+
// operator = "$gt";
|
319
|
+
// value = `${date}`;
|
320
|
+
// break;
|
321
|
+
|
322
|
+
// case "lessThan":
|
323
|
+
// operator = "$lt";
|
324
|
+
// value = `${date}`;
|
325
|
+
// break;
|
326
|
+
|
327
|
+
// case "blank":
|
328
|
+
// operator = "$eq";
|
329
|
+
// value = "";
|
330
|
+
// break;
|
331
|
+
|
332
|
+
// case "inRange":
|
333
|
+
// operator = "$gte";
|
334
|
+
// value = date;
|
335
|
+
// operator_to = "$lte";
|
336
|
+
// value_to = val.dateTo.substr(0, 10);
|
337
|
+
// break;
|
338
|
+
|
339
|
+
// case "notEqual":
|
340
|
+
// operator = "$regex";
|
341
|
+
// value = `^((?!${date}).)*$`;
|
342
|
+
// break;
|
343
|
+
|
344
|
+
// case "notBlank":
|
345
|
+
// operator = "$ne";
|
346
|
+
// value = "";
|
347
|
+
// break;
|
348
|
+
|
349
|
+
// default:
|
350
|
+
// operator = "$regex";
|
351
|
+
// value = `^${date}`;
|
352
|
+
// }
|
353
|
+
// }
|
354
|
+
|
355
|
+
// if (val.filterType === "string" || val.filterType === "text") {
|
356
|
+
// switch (val.type) {
|
357
|
+
// case "contains":
|
358
|
+
// operator = "$regex";
|
359
|
+
// value = `${val.filter}`;
|
360
|
+
// break;
|
361
|
+
|
362
|
+
// case "notContains":
|
363
|
+
// operator = "$regex";
|
364
|
+
// value = `^((?!${val.filter}).)*$`;
|
365
|
+
// break;
|
366
|
+
|
367
|
+
// case "equals":
|
368
|
+
// operator = "$eq";
|
369
|
+
// value = `${val.filter}`;
|
370
|
+
// break;
|
371
|
+
|
372
|
+
// case "notEqual":
|
373
|
+
// operator = "$ne";
|
374
|
+
// value = `${val.filter}`;
|
375
|
+
// break;
|
376
|
+
|
377
|
+
// case "startsWith":
|
378
|
+
// operator = "$regex";
|
379
|
+
// value = `^${val.filter}`;
|
380
|
+
// break;
|
381
|
+
|
382
|
+
// case "endsWith":
|
383
|
+
// operator = "$regex";
|
384
|
+
// value = `${val.filter}$`;
|
385
|
+
// break;
|
386
|
+
|
387
|
+
// case "blank":
|
388
|
+
// operator = "$eq";
|
389
|
+
// value = "";
|
390
|
+
// break;
|
391
|
+
|
392
|
+
// case "notBlank":
|
393
|
+
// operator = "$ne";
|
394
|
+
// value = "";
|
395
|
+
// break;
|
396
|
+
|
397
|
+
// default:
|
398
|
+
// value = "^" + val.filter;
|
399
|
+
// }
|
400
|
+
// }
|
401
|
+
|
402
|
+
// if (val.filterType === "number") {
|
403
|
+
// switch (val.type) {
|
404
|
+
// case "equals":
|
405
|
+
// operator = "$eq";
|
406
|
+
// value = val.filter;
|
407
|
+
// break;
|
408
|
+
|
409
|
+
// case "notEqual":
|
410
|
+
// operator = "$ne";
|
411
|
+
// value = val.filter;
|
412
|
+
// break;
|
413
|
+
|
414
|
+
// case "lessThanOrEqual":
|
415
|
+
// operator = "$lte";
|
416
|
+
// value = val.filter;
|
417
|
+
// break;
|
418
|
+
|
419
|
+
// case "greaterThanOrEqual":
|
420
|
+
// operator = "$gte";
|
421
|
+
// value = val.filter;
|
422
|
+
// break;
|
423
|
+
|
424
|
+
// case "lessThan":
|
425
|
+
// operator = "$lt";
|
426
|
+
// value = val.filter;
|
427
|
+
// break;
|
428
|
+
|
429
|
+
// case "greaterThan":
|
430
|
+
// operator = "$gt";
|
431
|
+
// value = val.filter;
|
432
|
+
// break;
|
433
|
+
|
434
|
+
// case "blank":
|
435
|
+
// operator = "$eq";
|
436
|
+
// value = 0;
|
437
|
+
// break;
|
438
|
+
|
439
|
+
// case "notBlank":
|
440
|
+
// operator = "$ne";
|
441
|
+
// value = 0;
|
442
|
+
// break;
|
443
|
+
|
444
|
+
// case "inRange":
|
445
|
+
// operator = "$gte";
|
446
|
+
// value = val.filter;
|
447
|
+
// operator_to = "$lte";
|
448
|
+
// value_to = val.filterTo;
|
449
|
+
// break;
|
450
|
+
|
451
|
+
// default:
|
452
|
+
// operator = "$eq";
|
453
|
+
// value = val.filter;
|
454
|
+
// }
|
455
|
+
// }
|
456
|
+
// if (!opt.selector[condition]) {
|
457
|
+
// opt.selector[condition] = [];
|
458
|
+
// }
|
459
|
+
// // if (!opt.selector[condition][field_name]) {
|
460
|
+
// // opt.selector[condition][field_name] = [];
|
461
|
+
// // }
|
462
|
+
// opt.selector[condition].push({ [field_name]: { [operator]: value } });
|
463
|
+
|
464
|
+
// if (operator_to) {
|
465
|
+
// opt.selector[condition].push({
|
466
|
+
// [field_name]: { [operator_to]: value_to },
|
467
|
+
// });
|
468
|
+
// // opt.selector[condition][field_name].push({
|
469
|
+
// // [operator_to]: value_to,
|
470
|
+
// // });
|
471
|
+
// }
|
472
|
+
// };
|
473
|
+
|
474
|
+
// if (!val.condition1) {
|
475
|
+
// make_selector(val);
|
476
|
+
// } else {
|
477
|
+
// condition = "$" + val.operator.toLowerCase();
|
478
|
+
// make_selector(val.condition1);
|
479
|
+
// make_selector(val.condition2);
|
480
|
+
// }
|
481
|
+
// }
|
482
|
+
// }
|
483
483
|
|
484
484
|
if (e.total_fields_info) {
|
485
485
|
fields = [];
|
@@ -517,22 +517,72 @@ const get_opt = function (e, table_obj) {
|
|
517
517
|
selector_new["udfData.data." + key] = val;
|
518
518
|
}
|
519
519
|
|
520
|
-
if (e.viewDbQuery) {
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
520
|
+
// if (e.viewDbQuery) {
|
521
|
+
// for (const [key, val] of Object.entries(table_obj.tableFields)) {
|
522
|
+
// if (e.viewDbQuery.includes(val.id)) {
|
523
|
+
// const replacer = new RegExp(val.id, "g");
|
524
|
+
// e.viewDbQuery = e.viewDbQuery.replace(
|
525
|
+
// replacer,
|
526
|
+
// "udfData.data." + val.data.field_id
|
527
|
+
// );
|
528
|
+
// }
|
529
|
+
// }
|
530
|
+
|
531
|
+
// let viewDbQuery = JSON.parse(e.viewDbQuery.replace(/\\/g, ""));
|
532
|
+
|
533
|
+
// for (const [key, val] of Object.entries(viewDbQuery)) {
|
534
|
+
// selector_new[key] = val;
|
535
|
+
// }
|
536
|
+
// }
|
537
|
+
|
538
|
+
function replaceKeysInQuery(query) {
|
539
|
+
const keys_to_replace = table_obj.tableFields.map((e) => {
|
540
|
+
return e.id;
|
541
|
+
});
|
542
|
+
|
543
|
+
// Helper function to recursively process the query object
|
544
|
+
function recursiveReplace(obj) {
|
545
|
+
if (typeof obj === "object" && obj !== null) {
|
546
|
+
// Create a new object to store the modified query
|
547
|
+
let newObj = Array.isArray(obj) ? [] : {};
|
548
|
+
|
549
|
+
// Traverse through the object
|
550
|
+
for (let key in obj) {
|
551
|
+
if (obj.hasOwnProperty(key)) {
|
552
|
+
// If the key is in the keys_to_replace array, replace it
|
553
|
+
let newKey = keys_to_replace.includes(key)
|
554
|
+
? `udfData.data.${key}`
|
555
|
+
: key;
|
556
|
+
|
557
|
+
// Recursively process nested objects
|
558
|
+
newObj[newKey] = recursiveReplace(obj[key]);
|
559
|
+
}
|
560
|
+
}
|
561
|
+
|
562
|
+
return newObj;
|
563
|
+
} else {
|
564
|
+
// If it's not an object or array, return the value as is
|
565
|
+
return obj;
|
528
566
|
}
|
529
567
|
}
|
530
568
|
|
531
|
-
|
569
|
+
// Start the recursive replacement
|
570
|
+
return recursiveReplace(query);
|
571
|
+
}
|
532
572
|
|
533
|
-
|
534
|
-
|
573
|
+
if (e.filterModelMongo) {
|
574
|
+
selector_new["$and"] = [replaceKeysInQuery(e.filterModelMongo)];
|
575
|
+
}
|
576
|
+
if (e.filterModelUserMongo) {
|
577
|
+
if (!selector_new["$and"]) {
|
578
|
+
selector_new["$and"] = [];
|
535
579
|
}
|
580
|
+
selector_new["$and"] = [replaceKeysInQuery(e.filterModelUserMongo)];
|
581
|
+
|
582
|
+
// selector_new["$and"] = {
|
583
|
+
// ...selector_new["$and"],
|
584
|
+
// ...replaceKeysInQuery(e.filterModelUserMongo),
|
585
|
+
// };
|
536
586
|
}
|
537
587
|
|
538
588
|
opt.selector = selector_new;
|