drapcode-utility 1.9.2 → 1.9.4
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.
- package/build/utils/query-parser.js +44 -31
- package/package.json +4 -4
|
@@ -685,7 +685,7 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
|
|
|
685
685
|
var searchAggregateQuery = [];
|
|
686
686
|
var likeQuery = [];
|
|
687
687
|
Object.entries(searchObj).forEach(function (_a) {
|
|
688
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
688
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
689
689
|
var key = _a[0], value = _a[1];
|
|
690
690
|
if (value) {
|
|
691
691
|
var searchQueryTypeKey = searchQueryTypeObj[key];
|
|
@@ -732,41 +732,54 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
|
|
|
732
732
|
_g));
|
|
733
733
|
}
|
|
734
734
|
else if (searchQueryTypeKey === "number") {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
$
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
735
|
+
if (key.startsWith("min_") || key.startsWith("max_")) {
|
|
736
|
+
var fieldKey = key.replace("min_", "");
|
|
737
|
+
fieldKey = fieldKey.replace("max_", "");
|
|
738
|
+
var numericValue = Number(value);
|
|
739
|
+
if (key.startsWith("min_")) {
|
|
740
|
+
likeQuery.push((_h = {}, _h["".concat(fieldKey)] = { $gte: numericValue }, _h));
|
|
741
|
+
}
|
|
742
|
+
else if (key.startsWith("max_")) {
|
|
743
|
+
likeQuery.push((_j = {}, _j["".concat(fieldKey)] = { $lte: numericValue }, _j));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
// handling value when db field type is Double/Int
|
|
748
|
+
searchAggregateQuery.push({
|
|
749
|
+
$addFields: (_k = {},
|
|
750
|
+
_k["_".concat(key)] = { $toString: { $toLong: "$".concat(key) } },
|
|
751
|
+
_k),
|
|
752
|
+
});
|
|
753
|
+
likeQuery.push((_l = {},
|
|
754
|
+
_l["_".concat(key)] = {
|
|
755
|
+
$regex: value,
|
|
756
|
+
$options: "i",
|
|
757
|
+
},
|
|
758
|
+
_l));
|
|
759
|
+
}
|
|
747
760
|
}
|
|
748
761
|
else if (["date", "createdAt", "time_slot"].includes(searchQueryTypeKey)) {
|
|
749
762
|
if (key.startsWith("start_") || key.startsWith("end_")) {
|
|
750
763
|
var fieldKey = key.replace("start_", "");
|
|
751
764
|
fieldKey = fieldKey.replace("end_", "");
|
|
752
765
|
searchAggregateQuery.push({
|
|
753
|
-
$addFields: (
|
|
754
|
-
|
|
755
|
-
|
|
766
|
+
$addFields: (_m = {},
|
|
767
|
+
_m["_".concat(key)] = { $toString: "$".concat(fieldKey) },
|
|
768
|
+
_m),
|
|
756
769
|
});
|
|
757
770
|
if (key.startsWith("start_")) {
|
|
758
|
-
likeQuery.push((
|
|
759
|
-
|
|
771
|
+
likeQuery.push((_o = {},
|
|
772
|
+
_o["_".concat(key)] = {
|
|
760
773
|
$gte: (0, date_util_1.timezoneDateParse)(value, false, true),
|
|
761
774
|
},
|
|
762
|
-
|
|
775
|
+
_o));
|
|
763
776
|
}
|
|
764
777
|
else if (key.startsWith("end_")) {
|
|
765
|
-
likeQuery.push((
|
|
766
|
-
|
|
778
|
+
likeQuery.push((_p = {},
|
|
779
|
+
_p["_".concat(key)] = {
|
|
767
780
|
$lt: (0, date_util_1.timezoneDateParse)(value, true),
|
|
768
781
|
},
|
|
769
|
-
|
|
782
|
+
_p));
|
|
770
783
|
}
|
|
771
784
|
}
|
|
772
785
|
}
|
|
@@ -774,25 +787,25 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
|
|
|
774
787
|
// if input is string and db field type is number
|
|
775
788
|
// converting db field to string first
|
|
776
789
|
searchAggregateQuery.push({
|
|
777
|
-
$addFields: (
|
|
778
|
-
|
|
779
|
-
|
|
790
|
+
$addFields: (_q = {},
|
|
791
|
+
_q["_".concat(key)] = { $toString: "$".concat(key) },
|
|
792
|
+
_q),
|
|
780
793
|
});
|
|
781
|
-
likeQuery.push((
|
|
782
|
-
|
|
794
|
+
likeQuery.push((_r = {},
|
|
795
|
+
_r["_".concat(key)] = {
|
|
783
796
|
$regex: value,
|
|
784
797
|
$options: "i",
|
|
785
798
|
},
|
|
786
|
-
|
|
799
|
+
_r));
|
|
787
800
|
}
|
|
788
801
|
}
|
|
789
802
|
else {
|
|
790
|
-
likeQuery.push((
|
|
791
|
-
|
|
803
|
+
likeQuery.push((_s = {},
|
|
804
|
+
_s[key] = {
|
|
792
805
|
$regex: value,
|
|
793
806
|
$options: "i",
|
|
794
807
|
},
|
|
795
|
-
|
|
808
|
+
_s));
|
|
796
809
|
}
|
|
797
810
|
}
|
|
798
811
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drapcode-utility",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@types/voca": "^1.4.2",
|
|
38
38
|
"axios": "^1.1.2",
|
|
39
39
|
"dompurify": "^3.1.7",
|
|
40
|
-
"drapcode-constant": "^1.6.
|
|
41
|
-
"drapcode-logger": "^1.3.
|
|
42
|
-
"drapcode-redis": "^1.2.
|
|
40
|
+
"drapcode-constant": "^1.6.7",
|
|
41
|
+
"drapcode-logger": "^1.3.3",
|
|
42
|
+
"drapcode-redis": "^1.2.3",
|
|
43
43
|
"exiftool-vendored": "^28.2.1",
|
|
44
44
|
"express": "^4.17.1",
|
|
45
45
|
"gm": "^1.25.0",
|