c2-mongoose 2.1.198 → 2.1.200
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.
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import mongoose, { ClientSession } from "mongoose";
|
|
2
2
|
import { SearchOptions, SearchResponse } from "../types/SearchResponse";
|
|
3
|
+
interface IPopulate {
|
|
4
|
+
path: string;
|
|
5
|
+
select: string;
|
|
6
|
+
populate: IPopulate;
|
|
7
|
+
}
|
|
3
8
|
declare abstract class SearchFlow {
|
|
4
9
|
[key: string]: any;
|
|
5
10
|
searchText: string;
|
|
@@ -20,7 +25,7 @@ declare abstract class SearchFlow {
|
|
|
20
25
|
buildProjections(): any;
|
|
21
26
|
buildProjectionNested(projectCurrent: any, field: string, include: boolean): any;
|
|
22
27
|
buildPopulate(): any;
|
|
23
|
-
buildPath(target: string, nested?: string):
|
|
28
|
+
buildPath(target: string, nested?: string): IPopulate;
|
|
24
29
|
buildOrdenation(): any;
|
|
25
30
|
buildRegex(searchText: string): RegExp;
|
|
26
31
|
searchNoPageable(model: mongoose.Model<any>, options: SearchOptions): Promise<any>;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -114,6 +114,12 @@ var SearchFlow = /** @class */ (function () {
|
|
|
114
114
|
populate.select = select;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
var existing = populates.find(function (populateAux) { return populateAux.path === populate.path; });
|
|
118
|
+
if (existing !== undefined) {
|
|
119
|
+
var populateAux = __assign(__assign({}, existing === null || existing === void 0 ? void 0 : existing.populate), { path: "".concat(existing.populate.path, " ").concat(populate.populate.path) });
|
|
120
|
+
existing.populate = populateAux;
|
|
121
|
+
return "continue";
|
|
122
|
+
}
|
|
117
123
|
populates.push(populate);
|
|
118
124
|
};
|
|
119
125
|
var this_1 = this;
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -4,6 +4,11 @@ import { SearchOptions, SearchResponse } from "../types/SearchResponse"
|
|
|
4
4
|
import { isEmpty, isNotEmpty } from "../utils/Utils"
|
|
5
5
|
import moment from "moment-timezone"
|
|
6
6
|
|
|
7
|
+
interface IPopulate {
|
|
8
|
+
path: string,
|
|
9
|
+
select: string,
|
|
10
|
+
populate: IPopulate
|
|
11
|
+
}
|
|
7
12
|
abstract class SearchFlow {
|
|
8
13
|
[key: string]: any
|
|
9
14
|
searchText: string
|
|
@@ -81,7 +86,7 @@ abstract class SearchFlow {
|
|
|
81
86
|
return
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
var populates = [] as
|
|
89
|
+
var populates = [] as IPopulate[]
|
|
85
90
|
for (var property of this.populate) {
|
|
86
91
|
let [first, ...rest] = property.split('.')
|
|
87
92
|
let nested = rest.join('.')
|
|
@@ -93,14 +98,28 @@ abstract class SearchFlow {
|
|
|
93
98
|
populate.select = select
|
|
94
99
|
}
|
|
95
100
|
}
|
|
101
|
+
|
|
102
|
+
const existing = populates.find((populateAux: IPopulate) => populateAux.path === populate.path)
|
|
103
|
+
if (existing !== undefined) {
|
|
104
|
+
const populateAux = {
|
|
105
|
+
...existing?.populate,
|
|
106
|
+
path: `${(existing as IPopulate).populate.path} ${populate.populate.path}`
|
|
107
|
+
}
|
|
108
|
+
existing.populate = populateAux
|
|
109
|
+
continue
|
|
110
|
+
}
|
|
111
|
+
|
|
96
112
|
populates.push(populate)
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
return populates
|
|
100
116
|
}
|
|
101
117
|
|
|
102
|
-
|
|
103
|
-
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
public buildPath(target: string, nested: string = ""): IPopulate {
|
|
122
|
+
var populate = {} as IPopulate
|
|
104
123
|
populate.path = target
|
|
105
124
|
if (isNotEmpty(nested)) {
|
|
106
125
|
let [first, ...rest] = nested.split('.')
|