c2-mongoose 2.1.361 → 2.1.363
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/flow/searcher/v2/GetOneByFilterFlow.d.ts +2 -1
- package/dist/flow/searcher/v2/GetOneByFilterFlow.js +4 -1
- package/dist/flow/searcher/v3/SearcherV3Flow.d.ts +1 -2
- package/dist/flow/searcher/v3/SearcherV3Flow.js +1 -4
- package/dist/flow/searcher/v3/item/OneToManyFlowItem.js +2 -1
- package/package.json +3 -1
- package/src/flow/searcher/v2/GetOneByFilterFlow.ts +4 -2
- package/src/flow/searcher/v3/SearcherV3Flow.ts +1 -2
- package/src/flow/searcher/v3/item/OneToManyFlowItem.ts +2 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
+
import { IForeingData } from "../v3/item/OneToManyFlowItem";
|
|
2
3
|
declare class GetOneByFilterFlow {
|
|
3
|
-
exec(params: any, model: mongoose.Model<any
|
|
4
|
+
exec(params: any, model: mongoose.Model<any>, oneToMany?: IForeingData[]): Promise<any>;
|
|
4
5
|
}
|
|
5
6
|
declare const _default: GetOneByFilterFlow;
|
|
6
7
|
export default _default;
|
|
@@ -51,10 +51,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
51
51
|
var MatchFlowItem_1 = __importDefault(require("./item/MatchFlowItem"));
|
|
52
52
|
var PopulateFlowItem_1 = __importDefault(require("./item/PopulateFlowItem"));
|
|
53
53
|
var ProjectFlowItem_1 = __importDefault(require("./item/ProjectFlowItem"));
|
|
54
|
+
var OneToManyFlowItem_1 = __importDefault(require("../v3/item/OneToManyFlowItem"));
|
|
54
55
|
var GetOneByFilterFlow = /** @class */ (function () {
|
|
55
56
|
function GetOneByFilterFlow() {
|
|
56
57
|
}
|
|
57
|
-
GetOneByFilterFlow.prototype.exec = function (params, model) {
|
|
58
|
+
GetOneByFilterFlow.prototype.exec = function (params, model, oneToMany) {
|
|
59
|
+
if (oneToMany === void 0) { oneToMany = []; }
|
|
58
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
61
|
var pipeline, result;
|
|
60
62
|
return __generator(this, function (_a) {
|
|
@@ -62,6 +64,7 @@ var GetOneByFilterFlow = /** @class */ (function () {
|
|
|
62
64
|
case 0:
|
|
63
65
|
pipeline = [];
|
|
64
66
|
pipeline = __spreadArray(__spreadArray([], pipeline, true), PopulateFlowItem_1.default.exec(params.populate, model), true);
|
|
67
|
+
pipeline = __spreadArray(__spreadArray([], pipeline, true), OneToManyFlowItem_1.default.execute(oneToMany), true);
|
|
65
68
|
pipeline = __spreadArray(__spreadArray([], pipeline, true), ProjectFlowItem_1.default.exec(params.select), true);
|
|
66
69
|
return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], MatchFlowItem_1.default.exec(params, model), true), pipeline, true), {
|
|
67
70
|
collation: {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import { IForeingData } from "./item/OneToManyFlowItem";
|
|
3
2
|
export interface IParams {
|
|
4
3
|
[key: string]: any;
|
|
5
4
|
mainFilter: any;
|
|
6
5
|
}
|
|
7
6
|
declare class SearcherV3Flow {
|
|
8
|
-
exec(params: IParams, model: mongoose.Model<any
|
|
7
|
+
exec(params: IParams, model: mongoose.Model<any>): Promise<any>;
|
|
9
8
|
}
|
|
10
9
|
declare const _default: SearcherV3Flow;
|
|
11
10
|
export default _default;
|
|
@@ -54,13 +54,11 @@ var PopulateFlowItem_1 = __importDefault(require("./item/PopulateFlowItem"));
|
|
|
54
54
|
var SortFlowItem_1 = __importDefault(require("./item/SortFlowItem"));
|
|
55
55
|
var ProjectFlowItem_1 = __importDefault(require("./item/ProjectFlowItem"));
|
|
56
56
|
var BuildPaginationDataFlowItem_1 = __importDefault(require("./item/BuildPaginationDataFlowItem"));
|
|
57
|
-
var OneToManyFlowItem_1 = __importDefault(require("./item/OneToManyFlowItem"));
|
|
58
57
|
var SearcherV3Flow = /** @class */ (function () {
|
|
59
58
|
function SearcherV3Flow() {
|
|
60
59
|
}
|
|
61
|
-
SearcherV3Flow.prototype.exec = function (params, model
|
|
60
|
+
SearcherV3Flow.prototype.exec = function (params, model) {
|
|
62
61
|
var _a, _b, _c;
|
|
63
|
-
if (oneToMany === void 0) { oneToMany = []; }
|
|
64
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
63
|
var facet, pipelineFacetPaging, pipelineFacetItems, mainFilters, result, ret;
|
|
66
64
|
return __generator(this, function (_d) {
|
|
@@ -73,7 +71,6 @@ var SearcherV3Flow = /** @class */ (function () {
|
|
|
73
71
|
pipelineFacetItems = [];
|
|
74
72
|
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), GroupFlowItem_1.default.execute(params.groupBy, params.sumFields, params.groupDetailed, model), true);
|
|
75
73
|
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), PopulateFlowItem_1.default.execute(params.populate, model), true);
|
|
76
|
-
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), OneToManyFlowItem_1.default.execute(oneToMany), true);
|
|
77
74
|
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), MatchFlowItem_1.default.execute(params, model), true);
|
|
78
75
|
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), SortFlowItem_1.default.execute(params.orderBy, params.orderSense), true);
|
|
79
76
|
pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), ProjectFlowItem_1.default.execute(params.select), true);
|
|
@@ -9,6 +9,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
var lodash_1 = require("lodash");
|
|
12
13
|
var OneToManyFlowItem = /** @class */ (function () {
|
|
13
14
|
function OneToManyFlowItem() {
|
|
14
15
|
}
|
|
@@ -21,7 +22,7 @@ var OneToManyFlowItem = /** @class */ (function () {
|
|
|
21
22
|
from: foreing.collectionChild,
|
|
22
23
|
localField: "_id",
|
|
23
24
|
foreignField: foreing.parentFieldOnChild,
|
|
24
|
-
as: foreing.collectionChild
|
|
25
|
+
as: (0, lodash_1.camelCase)(foreing.collectionChild)
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-mongoose",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.363",
|
|
4
4
|
"description": "Lib to make any search in database mongoose and use as basic crud",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,11 +30,13 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"dotenv": "^16.0.3",
|
|
32
32
|
"express-http-context": "^1.2.4",
|
|
33
|
+
"lodash": "^4.17.21",
|
|
33
34
|
"moment": "^2.29.4",
|
|
34
35
|
"moment-timezone": "^0.5.43",
|
|
35
36
|
"mongoose": "8.16.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
39
|
+
"@types/lodash": "^4.17.20",
|
|
38
40
|
"typescript": "^4.9.5"
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -2,14 +2,16 @@ import mongoose from "mongoose"
|
|
|
2
2
|
import MatchFlowItem from "./item/MatchFlowItem"
|
|
3
3
|
import PopulateFlowItem from "./item/PopulateFlowItem"
|
|
4
4
|
import ProjectFlowItem from "./item/ProjectFlowItem"
|
|
5
|
+
import OneToManyFlowItem, { IForeingData } from "../v3/item/OneToManyFlowItem"
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class GetOneByFilterFlow {
|
|
8
9
|
|
|
9
|
-
async exec(params: any, model: mongoose.Model<any
|
|
10
|
+
async exec(params: any, model: mongoose.Model<any>, oneToMany: IForeingData[] = []) {
|
|
10
11
|
|
|
11
12
|
let pipeline: any[] = []
|
|
12
|
-
pipeline = [...pipeline, ...PopulateFlowItem.exec(params.populate, model)
|
|
13
|
+
pipeline = [...pipeline, ...PopulateFlowItem.exec(params.populate, model)]
|
|
14
|
+
pipeline = [...pipeline, ...OneToManyFlowItem.execute(oneToMany)]
|
|
13
15
|
pipeline = [...pipeline, ...ProjectFlowItem.exec(params.select)]
|
|
14
16
|
|
|
15
17
|
let result = await model.aggregate([
|
|
@@ -14,7 +14,7 @@ export interface IParams {
|
|
|
14
14
|
|
|
15
15
|
class SearcherV3Flow {
|
|
16
16
|
|
|
17
|
-
async exec(params: IParams, model: mongoose.Model<any
|
|
17
|
+
async exec(params: IParams, model: mongoose.Model<any>) {
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
params.page = Number(params.page ?? 1)
|
|
@@ -25,7 +25,6 @@ class SearcherV3Flow {
|
|
|
25
25
|
let pipelineFacetItems: any[] = []
|
|
26
26
|
pipelineFacetItems = [...pipelineFacetItems, ...GroupFlowItem.execute(params.groupBy, params.sumFields, params.groupDetailed, model)]
|
|
27
27
|
pipelineFacetItems = [...pipelineFacetItems, ...PopulateFlowItem.execute(params.populate, model)]
|
|
28
|
-
pipelineFacetItems = [...pipelineFacetItems, ...OneToManyFlowItem.execute(oneToMany)]
|
|
29
28
|
pipelineFacetItems = [...pipelineFacetItems, ...MatchFlowItem.execute(params, model)]
|
|
30
29
|
pipelineFacetItems = [...pipelineFacetItems, ...SortFlowItem.execute(params.orderBy, params.orderSense)]
|
|
31
30
|
pipelineFacetItems = [...pipelineFacetItems, ...ProjectFlowItem.execute(params.select)]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { camelCase } from "lodash"
|
|
3
2
|
export interface IForeingData {
|
|
4
3
|
collectionChild: string;
|
|
5
4
|
parentFieldOnChild: string;
|
|
@@ -15,7 +14,7 @@ class OneToManyFlowItem {
|
|
|
15
14
|
from: foreing.collectionChild, // The collection where user data is stored
|
|
16
15
|
localField: "_id",
|
|
17
16
|
foreignField: foreing.parentFieldOnChild,
|
|
18
|
-
as: foreing.collectionChild
|
|
17
|
+
as: camelCase(foreing.collectionChild)
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
]
|