@xuda.io/xuda-dbs-plugin-xuda 1.0.197 → 1.0.198

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/server.js +34 -0
  3. package/studio.mjs +5 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-dbs-plugin-xuda",
3
- "version": "1.0.197",
3
+ "version": "1.0.198",
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
@@ -525,6 +525,40 @@ const get_opt = function (e, table_obj) {
525
525
  return recursiveReplace(query);
526
526
  }
527
527
 
528
+ function replaceRegexOptions(query) {
529
+ // Helper function to recursively process the query object
530
+ function recursiveReplace(obj) {
531
+ if (typeof obj === "object" && obj !== null) {
532
+ // Create a new object to store the modified query
533
+ let newObj = Array.isArray(obj) ? [] : {};
534
+
535
+ // Traverse through the object
536
+ for (let key in obj) {
537
+ if (obj.hasOwnProperty(key)) {
538
+ if (key === "$regex") {
539
+ newObj[key] = obj.$options
540
+ ? `(?${obj.$options})${obj[key]}`
541
+ : obj[key];
542
+ return newObj;
543
+ }
544
+
545
+ // Recursively process nested objects
546
+
547
+ newObj[key] = recursiveReplace(obj[key]);
548
+ }
549
+ }
550
+
551
+ return newObj;
552
+ } else {
553
+ // If it's not an object or array, return the value as is
554
+ return obj;
555
+ }
556
+ }
557
+
558
+ // Start the recursive replacement
559
+ return recursiveReplace(query);
560
+ }
561
+
528
562
  if (e.filterModelMongo) {
529
563
  selector_new["$and"] = [replaceKeysInQuery(JSON.parse(e.filterModelMongo))];
530
564
  }
package/studio.mjs CHANGED
@@ -586,13 +586,14 @@ const get_opt = function (e, table_obj) {
586
586
  // : key;
587
587
 
588
588
  if (key === "$regex") {
589
- obj[key] = RegExp(obj[key], obj.$options);
589
+ newObj[key] = RegExp(obj[key], obj.$options);
590
+ return newObj;
590
591
  }
591
592
 
592
593
  // Recursively process nested objects
593
- if (key !== "$options") {
594
- newObj[key] = recursiveReplace(obj[key]);
595
- }
594
+ // if (key !== "$options") {
595
+ newObj[key] = recursiveReplace(obj[key]);
596
+ // }
596
597
  }
597
598
  }
598
599