@thisisagile/easy-mongo 12.22.25 → 12.22.26
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/Aggregation.d.ts +39 -0
- package/dist/Aggregation.js +17 -0
- package/dist/Aggregation.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Aggregation.ts +16 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Id, Optional } from '@thisisagile/easy';
|
|
2
|
+
import { Filter, FindOptions } from './MongoProvider';
|
|
3
|
+
export declare const asc = 1;
|
|
4
|
+
export declare const desc = -1;
|
|
5
|
+
export declare const aggregation: {
|
|
6
|
+
match: (f: Filter) => {
|
|
7
|
+
$match: Filter<unknown>;
|
|
8
|
+
};
|
|
9
|
+
id: (id: Id) => {
|
|
10
|
+
$match: Filter<unknown>;
|
|
11
|
+
};
|
|
12
|
+
eq: (key: string, value: Id) => {
|
|
13
|
+
$match: Filter<unknown>;
|
|
14
|
+
};
|
|
15
|
+
sum: (to: string, from?: string) => {
|
|
16
|
+
[x: string]: {
|
|
17
|
+
$sum: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
group: (id: Id, g: Filter) => {
|
|
21
|
+
$group: {
|
|
22
|
+
_id: Id | import("mongodb").Condition<import("bson").ObjectID>;
|
|
23
|
+
$and?: import("mongodb").Filter<import("mongodb").WithId<unknown>>[] | undefined;
|
|
24
|
+
$nor?: import("mongodb").Filter<import("mongodb").WithId<unknown>>[] | undefined;
|
|
25
|
+
$or?: import("mongodb").Filter<import("mongodb").WithId<unknown>>[] | undefined;
|
|
26
|
+
$text?: {
|
|
27
|
+
$search: string;
|
|
28
|
+
$language?: string | undefined;
|
|
29
|
+
$caseSensitive?: boolean | undefined;
|
|
30
|
+
$diacriticSensitive?: boolean | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
$where?: string | ((this: import("mongodb").WithId<unknown>) => boolean) | undefined;
|
|
33
|
+
$comment?: string | import("bson").Document | undefined;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
skip: ({ skip: $skip }: FindOptions) => Optional<Filter>;
|
|
37
|
+
take: ({ take: $limit }: FindOptions) => Optional<Filter>;
|
|
38
|
+
sort: ($sort: Record<string, typeof asc | typeof desc>) => Optional<Filter>;
|
|
39
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.aggregation = exports.desc = exports.asc = void 0;
|
|
4
|
+
const easy_1 = require("@thisisagile/easy");
|
|
5
|
+
exports.asc = 1;
|
|
6
|
+
exports.desc = -1;
|
|
7
|
+
exports.aggregation = {
|
|
8
|
+
match: (f) => ({ $match: f }),
|
|
9
|
+
id: (id) => exports.aggregation.match({ id }),
|
|
10
|
+
eq: (key, value) => exports.aggregation.match({ [key]: value }),
|
|
11
|
+
sum: (to, from = to) => ({ [to]: { $sum: `$${from}` } }),
|
|
12
|
+
group: (id, g) => ({ $group: { _id: id, ...g } }),
|
|
13
|
+
skip: ({ skip: $skip }) => (0, easy_1.ifDefined)($skip, { $skip }),
|
|
14
|
+
take: ({ take: $limit }) => (0, easy_1.ifDefined)($limit, { $limit }),
|
|
15
|
+
sort: ($sort) => ((0, easy_1.isPresent)($sort) ? { $sort } : undefined),
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=Aggregation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Aggregation.js","sourceRoot":"","sources":["../src/Aggregation.ts"],"names":[],"mappings":";;;AAAA,4CAAuE;AAG1D,QAAA,GAAG,GAAG,CAAC,CAAC;AACR,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC;AAEV,QAAA,WAAW,GAAG;IACzB,KAAK,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACrC,EAAE,EAAE,CAAC,EAAM,EAAE,EAAE,CAAC,mBAAW,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC;IACzC,EAAE,EAAE,CAAC,GAAW,EAAE,KAAS,EAAE,EAAE,CAAC,mBAAW,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;IACnE,GAAG,EAAE,CAAC,EAAU,EAAE,OAAe,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;IACxE,KAAK,EAAE,CAAC,EAAM,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;IAC7D,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAe,EAAoB,EAAE,CAAC,IAAA,gBAAS,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;IACrF,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAe,EAAoB,EAAE,CAAC,IAAA,gBAAS,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC;IACxF,IAAI,EAAE,CAAC,KAA+C,EAAoB,EAAE,CAAC,CAAC,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;CACxH,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Aggregation"), exports);
|
|
17
18
|
__exportStar(require("./Collection"), exports);
|
|
18
19
|
__exportStar(require("./MongoGateway"), exports);
|
|
19
20
|
__exportStar(require("./MongoProvider"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B;AAC/B,kDAAgC;AAChC,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B;AAC7B,iDAA+B;AAC/B,kDAAgC;AAChC,0CAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy-mongo",
|
|
3
|
-
"version": "12.22.
|
|
3
|
+
"version": "12.22.26",
|
|
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": "12.22.
|
|
34
|
+
"@thisisagile/easy-test": "12.22.26"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thisisagile/easy": "^12.22.
|
|
37
|
+
"@thisisagile/easy": "^12.22.26",
|
|
38
38
|
"mongodb": "^4.14.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Id, ifDefined, isPresent, Optional } from '@thisisagile/easy';
|
|
2
|
+
import { Filter, FindOptions } from './MongoProvider';
|
|
3
|
+
|
|
4
|
+
export const asc = 1;
|
|
5
|
+
export const desc = -1;
|
|
6
|
+
|
|
7
|
+
export const aggregation = {
|
|
8
|
+
match: (f: Filter) => ({ $match: f }),
|
|
9
|
+
id: (id: Id) => aggregation.match({ id }),
|
|
10
|
+
eq: (key: string, value: Id) => aggregation.match({ [key]: value }),
|
|
11
|
+
sum: (to: string, from: string = to) => ({ [to]: { $sum: `$${from}` } }),
|
|
12
|
+
group: (id: Id, g: Filter) => ({ $group: { _id: id, ...g } }),
|
|
13
|
+
skip: ({ skip: $skip }: FindOptions): Optional<Filter> => ifDefined($skip, { $skip }),
|
|
14
|
+
take: ({ take: $limit }: FindOptions): Optional<Filter> => ifDefined($limit, { $limit }),
|
|
15
|
+
sort: ($sort: Record<string, typeof asc | typeof desc>): Optional<Filter> => (isPresent($sort) ? { $sort } : undefined),
|
|
16
|
+
};
|
package/src/index.ts
CHANGED