@xuda.io/xuda-dbs-plugin-xuda 1.0.195 → 1.0.197
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/studio.mjs +43 -7
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.197",
|
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/studio.mjs
CHANGED
@@ -570,21 +570,57 @@ const get_opt = function (e, table_obj) {
|
|
570
570
|
return recursiveReplace(query);
|
571
571
|
}
|
572
572
|
|
573
|
+
function replaceRegexOptions(query) {
|
574
|
+
// Helper function to recursively process the query object
|
575
|
+
function recursiveReplace(obj) {
|
576
|
+
if (typeof obj === "object" && obj !== null) {
|
577
|
+
// Create a new object to store the modified query
|
578
|
+
let newObj = Array.isArray(obj) ? [] : {};
|
579
|
+
|
580
|
+
// Traverse through the object
|
581
|
+
for (let key in obj) {
|
582
|
+
if (obj.hasOwnProperty(key)) {
|
583
|
+
// If the key is in the keys_to_replace array, replace it
|
584
|
+
// let newKey = keys_to_replace.includes(key)
|
585
|
+
// ? `udfData.data.${key}`
|
586
|
+
// : key;
|
587
|
+
|
588
|
+
if (key === "$regex") {
|
589
|
+
obj[key] = RegExp(obj[key], obj.$options);
|
590
|
+
}
|
591
|
+
|
592
|
+
// Recursively process nested objects
|
593
|
+
if (key !== "$options") {
|
594
|
+
newObj[key] = recursiveReplace(obj[key]);
|
595
|
+
}
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
return newObj;
|
600
|
+
} else {
|
601
|
+
// If it's not an object or array, return the value as is
|
602
|
+
return obj;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
|
606
|
+
// Start the recursive replacement
|
607
|
+
return recursiveReplace(query);
|
608
|
+
}
|
609
|
+
|
573
610
|
if (e.filterModelMongo) {
|
574
|
-
selector_new["$and"] = [
|
611
|
+
selector_new["$and"] = [
|
612
|
+
replaceRegexOptions(replaceKeysInQuery(JSON.parse(e.filterModelMongo))),
|
613
|
+
];
|
575
614
|
}
|
576
615
|
if (e.filterModelUserMongo) {
|
577
616
|
if (!selector_new["$and"]) {
|
578
617
|
selector_new["$and"] = [];
|
579
618
|
}
|
580
619
|
selector_new["$and"].push(
|
581
|
-
|
620
|
+
replaceRegexOptions(
|
621
|
+
replaceKeysInQuery(JSON.parse(e.filterModelUserMongo))
|
622
|
+
)
|
582
623
|
);
|
583
|
-
|
584
|
-
// selector_new["$and"] = {
|
585
|
-
// ...selector_new["$and"],
|
586
|
-
// ...replaceKeysInQuery(e.filterModelUserMongo),
|
587
|
-
// };
|
588
624
|
}
|
589
625
|
|
590
626
|
opt.selector = selector_new;
|