@geekbears/gb-mongoose-query-parser 1.3.10 → 1.3.12
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/lib/query-parser-helper.js +11 -4
- package/package.json +3 -2
|
@@ -51,6 +51,7 @@ exports.QueryParser = void 0;
|
|
|
51
51
|
var mongoose_1 = require("mongoose");
|
|
52
52
|
var lodash_1 = require("lodash");
|
|
53
53
|
var query_parser_1 = require("./query-parser");
|
|
54
|
+
var class_validator_1 = require("class-validator");
|
|
54
55
|
/**
|
|
55
56
|
* Helper class
|
|
56
57
|
* Implements the `MongooseQueryParser` and exposes a single method to execute queries on models
|
|
@@ -336,19 +337,25 @@ exports.QueryParser = QueryParser;
|
|
|
336
337
|
*/
|
|
337
338
|
function transformFilter(filter) {
|
|
338
339
|
var walk = function (obj) {
|
|
339
|
-
|
|
340
|
+
var _loop_1 = function (key) {
|
|
340
341
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
341
342
|
var value = obj[key];
|
|
342
343
|
var validId = (0, mongoose_1.isValidObjectId)(value);
|
|
343
|
-
if (validId)
|
|
344
|
+
if (validId && (0, class_validator_1.isMongoId)(value))
|
|
344
345
|
obj[key] = mongoose_1.Types.ObjectId.createFromHexString(value.toString());
|
|
345
|
-
else
|
|
346
|
-
|
|
346
|
+
else {
|
|
347
|
+
setTimeout(function () {
|
|
348
|
+
walk(obj[key]);
|
|
349
|
+
}, 0);
|
|
350
|
+
}
|
|
347
351
|
// if (typeof value === 'object') {
|
|
348
352
|
// console.log('walking......');
|
|
349
353
|
// walk(obj[key]);
|
|
350
354
|
// } else obj[key] = Types.ObjectId.isValid(value) ? new Types.ObjectId(value) : value;
|
|
351
355
|
}
|
|
356
|
+
};
|
|
357
|
+
for (var key in obj) {
|
|
358
|
+
_loop_1(key);
|
|
352
359
|
}
|
|
353
360
|
return obj;
|
|
354
361
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekbears/gb-mongoose-query-parser",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.12",
|
|
4
4
|
"description": "Convert url query string to MongooseJs friendly query object including advanced filtering, sorting, population, deep population, string template, type casting and many more...",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"mongoose": "7 - 9",
|
|
54
|
-
"qs": "^6.10.1"
|
|
54
|
+
"qs": "^6.10.1",
|
|
55
|
+
"class-validator": "0.10 - 0.15"
|
|
55
56
|
}
|
|
56
57
|
}
|