@xuda.io/xuda-dbs-plugin-xuda 1.0.203 → 1.0.205
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 +4 -19
- package/studio.mjs +8 -214
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.205",
|
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
@@ -559,7 +559,7 @@ const get_opt = function (e, table_obj) {
|
|
559
559
|
return recursiveReplace(query);
|
560
560
|
}
|
561
561
|
|
562
|
-
if (e.filterModelMongo) {
|
562
|
+
if (e.dataSourceFilterModelType === "query" && e.filterModelMongo) {
|
563
563
|
selector_new["$and"] = [
|
564
564
|
replaceRegexOptions(replaceKeysInQuery(JSON.parse(e.filterModelMongo))),
|
565
565
|
];
|
@@ -574,25 +574,10 @@ const get_opt = function (e, table_obj) {
|
|
574
574
|
)
|
575
575
|
);
|
576
576
|
}
|
577
|
-
for (const [key, val] of Object.entries(opt.selector)) {
|
578
|
-
selector_new["udfData.data." + key] = val;
|
579
|
-
}
|
580
|
-
|
581
|
-
if (e.viewDbQuery) {
|
582
|
-
for (const [key, val] of Object.entries(table_obj.tableFields)) {
|
583
|
-
if (e.viewDbQuery.includes(val.id)) {
|
584
|
-
const replacer = new RegExp(val.id, "g");
|
585
|
-
e.viewDbQuery = e.viewDbQuery.replace(
|
586
|
-
replacer,
|
587
|
-
"udfData.data." + val.data.field_id
|
588
|
-
);
|
589
|
-
}
|
590
|
-
}
|
591
|
-
|
592
|
-
let viewDbQuery = JSON.parse(e.viewDbQuery.replace(/\\/g, ""));
|
593
577
|
|
594
|
-
|
595
|
-
|
578
|
+
if (e.dataSourceFilterModelType === "index") {
|
579
|
+
for (const [key, val] of Object.entries(opt.selector)) {
|
580
|
+
selector_new["udfData.data." + key] = val;
|
596
581
|
}
|
597
582
|
}
|
598
583
|
|
package/studio.mjs
CHANGED
@@ -295,192 +295,6 @@ const get_opt = function (e, table_obj) {
|
|
295
295
|
}
|
296
296
|
}
|
297
297
|
|
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
|
-
|
484
298
|
if (e.total_fields_info) {
|
485
299
|
fields = [];
|
486
300
|
for (const [key, val] of Object.entries(JSON.parse(e.total_fields_info))) {
|
@@ -509,32 +323,6 @@ const get_opt = function (e, table_obj) {
|
|
509
323
|
|
510
324
|
var selector_new = {};
|
511
325
|
|
512
|
-
// for (const [key, val] of Object.entries(opt.selector)) {
|
513
|
-
// if (key.substring(0, 1) === "$") {
|
514
|
-
// selector_new[key] = val;
|
515
|
-
// continue;
|
516
|
-
// }
|
517
|
-
// selector_new["udfData.data." + key] = val;
|
518
|
-
// }
|
519
|
-
|
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
326
|
function replaceKeysInQuery(query) {
|
539
327
|
const keys_to_replace = table_obj.tableFields.map((e) => {
|
540
328
|
return e.id;
|
@@ -586,7 +374,7 @@ const get_opt = function (e, table_obj) {
|
|
586
374
|
// : key;
|
587
375
|
|
588
376
|
if (key === "$regex") {
|
589
|
-
newObj[key] =
|
377
|
+
newObj[key] = obj[key]; // RegExp(obj[key], obj.$options);
|
590
378
|
return newObj;
|
591
379
|
}
|
592
380
|
|
@@ -608,7 +396,7 @@ const get_opt = function (e, table_obj) {
|
|
608
396
|
return recursiveReplace(query);
|
609
397
|
}
|
610
398
|
|
611
|
-
if (e.filterModelMongo) {
|
399
|
+
if (e.dataSourceFilterModelType === "query" && e.filterModelMongo) {
|
612
400
|
selector_new["$and"] = [
|
613
401
|
replaceRegexOptions(replaceKeysInQuery(JSON.parse(e.filterModelMongo))),
|
614
402
|
];
|
@@ -624,6 +412,12 @@ const get_opt = function (e, table_obj) {
|
|
624
412
|
);
|
625
413
|
}
|
626
414
|
|
415
|
+
if (e.dataSourceFilterModelType === "index") {
|
416
|
+
for (const [key, val] of Object.entries(opt.selector)) {
|
417
|
+
selector_new["udfData.data." + key] = val;
|
418
|
+
}
|
419
|
+
}
|
420
|
+
|
627
421
|
opt.selector = selector_new;
|
628
422
|
opt.selector["udfData.udffileid"] = e.table_id;
|
629
423
|
opt.selector["docType"] = "database";
|