@xuda.io/xuda-dbs-plugin-xuda 1.0.303 → 1.0.305

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 (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +14 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-dbs-plugin-xuda",
3
- "version": "1.0.303",
3
+ "version": "1.0.305",
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
@@ -285,7 +285,12 @@ const get_opt = function (e, table_obj) {
285
285
  for (const [key, val] of Object.entries(opt.fields)) {
286
286
  opt.fields[key] = "udfData.data." + val;
287
287
  }
288
- if (!e?.sortModel || !JSON.parse(e.sortModel).length) {
288
+
289
+ const _sort_model =
290
+ typeof e.sortModel === "string" ? JSON.parse(e.sortModel) : e.sortModel;
291
+
292
+ // if (!e?.sortModel || !JSON.parse(e.sortModel).length) {
293
+ if (!_sort_model.length) {
289
294
  // added 2021 09 10
290
295
  if (opt.sort) {
291
296
  for (const [key, val] of Object.entries(opt.sort)) {
@@ -372,14 +377,18 @@ const get_opt = function (e, table_obj) {
372
377
  replaceRegexOptions(replaceKeysInQuery(JSON.parse(e.filterModelMongo))),
373
378
  ];
374
379
  }
375
- if (e.filterModelUserMongo) {
380
+
381
+ const _filterModelUserMongo =
382
+ typeof e.filterModelUserMongo === "string"
383
+ ? JSON.parse(e.filterModelUserMongo)
384
+ : e.filterModelUserMongo;
385
+
386
+ if (!_.isEmpty(_filterModelUserMongo)) {
376
387
  if (!selector_new["$and"]) {
377
388
  selector_new["$and"] = [];
378
389
  }
379
390
  selector_new["$and"].push(
380
- replaceRegexOptions(
381
- replaceKeysInQuery(JSON.parse(e.filterModelUserMongo))
382
- )
391
+ replaceRegexOptions(replaceKeysInQuery(_filterModelUserMongo))
383
392
  );
384
393
  }
385
394