c2-mongoose 2.1.198 → 2.1.199
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,15 @@ 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 ((0, Utils_1.isNotEmpty)(existing)) {
|
|
119
|
+
existing.populate = {
|
|
120
|
+
path: "".concat(existing.path, " ").concat(populate.path),
|
|
121
|
+
populate: populate.populate,
|
|
122
|
+
select: populate.select
|
|
123
|
+
};
|
|
124
|
+
return "continue";
|
|
125
|
+
}
|
|
117
126
|
populates.push(populate);
|
|
118
127
|
};
|
|
119
128
|
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 (isNotEmpty(existing)) {
|
|
104
|
+
(existing as IPopulate).populate = {
|
|
105
|
+
path: `${(existing as IPopulate).path} ${populate.path}`,
|
|
106
|
+
populate: populate.populate,
|
|
107
|
+
select: populate.select
|
|
108
|
+
}
|
|
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('.')
|