@thisisagile/easy-mongo 9.5.9 → 10.2.0
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/dist/Utils.js +6 -9
- package/dist/Utils.js.map +1 -1
- package/package.json +3 -3
- package/src/Utils.ts +7 -21
package/dist/Utils.js
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toMongoType = void 0;
|
|
4
4
|
const easy_1 = require("@thisisagile/easy");
|
|
5
|
-
const toMongoType = (input) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.map(([k, i]) => [k, (0, exports.toMongoType)(i)])))
|
|
12
|
-
.else(input);
|
|
13
|
-
};
|
|
5
|
+
const toMongoType = (input) => (0, easy_1.choose)(input)
|
|
6
|
+
.type(easy_1.isIsoDateString, i => new easy_1.DateTime(i).toDate())
|
|
7
|
+
.type(easy_1.isArray, a => a.map((i) => (0, exports.toMongoType)(i)))
|
|
8
|
+
.type(easy_1.isDate, d => d)
|
|
9
|
+
.type(easy_1.isObject, o => Object.fromEntries((0, easy_1.meta)(o).entries().map(([k, i]) => [k, (0, exports.toMongoType)(i)])))
|
|
10
|
+
.else(input);
|
|
14
11
|
exports.toMongoType = toMongoType;
|
|
15
12
|
//# sourceMappingURL=Utils.js.map
|
package/dist/Utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;;AAAA,4CAA6G;AAEtG,MAAM,WAAW,GAAG,CAAC,KAAc,EAAQ,EAAE
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;;AAAA,4CAA6G;AAEtG,MAAM,WAAW,GAAG,CAAC,KAAc,EAAQ,EAAE,CAClD,IAAA,aAAM,EAAC,KAAK,CAAC;KACZ,IAAI,CAAC,sBAAe,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,eAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAS,CAAC;KAC3D,IAAI,CAAC,cAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,IAAA,mBAAW,EAAC,CAAC,CAAC,CAAC,CAAC;KACrD,IAAI,CAAC,aAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACpB,IAAI,CAAC,eAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAA,WAAI,EAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAA,mBAAW,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/F,IAAI,CAAC,KAAK,CAAC,CAAC;AANF,QAAA,WAAW,eAMT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy-mongo",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "Add support for MongoDB",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "
|
|
34
|
+
"@thisisagile/easy-test": "10.2.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thisisagile/easy": "
|
|
37
|
+
"@thisisagile/easy": "10.2.0",
|
|
38
38
|
"mongodb": "^4.5.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/Utils.ts
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import { choose, DateTime, isArray, isDate, isIsoDateString, isObject, Json, meta } from '@thisisagile/easy';
|
|
2
2
|
|
|
3
|
-
export const toMongoType = (input: unknown): Json =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
v => isArray(v),
|
|
11
|
-
(v: any) => v.map((i: any) => toMongoType(i))
|
|
12
|
-
)
|
|
13
|
-
.case(
|
|
14
|
-
v => isObject(v) && !isDate(v),
|
|
15
|
-
(v: any) =>
|
|
16
|
-
Object.fromEntries(
|
|
17
|
-
meta(v)
|
|
18
|
-
.entries()
|
|
19
|
-
.map(([k, i]) => [k, toMongoType(i)])
|
|
20
|
-
)
|
|
21
|
-
)
|
|
22
|
-
.else(input);
|
|
23
|
-
};
|
|
3
|
+
export const toMongoType = (input: unknown): Json =>
|
|
4
|
+
choose(input)
|
|
5
|
+
.type(isIsoDateString, i => new DateTime(i).toDate() as any)
|
|
6
|
+
.type(isArray, a => a.map((i: any) => toMongoType(i)))
|
|
7
|
+
.type(isDate, d => d)
|
|
8
|
+
.type(isObject, o => Object.fromEntries(meta(o).entries().map(([k, i]) => [k, toMongoType(i)])))
|
|
9
|
+
.else(input);
|