c2-mongoose 2.1.0 → 2.1.2
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/CrudFlow.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import SearchFlow from "./SearchFlow";
|
|
|
4
4
|
declare class CrudFlow<D> {
|
|
5
5
|
private repository;
|
|
6
6
|
private search;
|
|
7
|
-
constructor(repository: mongoose.Model<any>, search
|
|
7
|
+
constructor(repository: mongoose.Model<any>, search?: SearchFlow);
|
|
8
|
+
prepareSearch(search: SearchFlow): void;
|
|
8
9
|
create(data: any, session?: any): Promise<any[]>;
|
|
9
10
|
delete(id: string, session?: any): Promise<void>;
|
|
10
11
|
update(id: string, data: D, session?: any): Promise<D>;
|
package/dist/flow/CrudFlow.js
CHANGED
|
@@ -41,6 +41,9 @@ var CrudFlow = /** @class */ (function () {
|
|
|
41
41
|
this.repository = repository;
|
|
42
42
|
this.search = search;
|
|
43
43
|
}
|
|
44
|
+
CrudFlow.prototype.prepareSearch = function (search) {
|
|
45
|
+
this.search = search;
|
|
46
|
+
};
|
|
44
47
|
CrudFlow.prototype.create = function (data, session) {
|
|
45
48
|
if (session === void 0) { session = undefined; }
|
|
46
49
|
return __awaiter(this, void 0, void 0, function () {
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -95,7 +95,8 @@ var SearchFlow = /** @class */ (function () {
|
|
|
95
95
|
if ((0, Utils_1.isEmpty)(this.populate)) {
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
var
|
|
98
|
+
var populateStr = this.populate;
|
|
99
|
+
var propertiesArray = populateStr.split(',');
|
|
99
100
|
var populates = [];
|
|
100
101
|
for (var _i = 0, propertiesArray_1 = propertiesArray; _i < propertiesArray_1.length; _i++) {
|
|
101
102
|
var property = propertiesArray_1[_i];
|
package/package.json
CHANGED
package/src/flow/CrudFlow.ts
CHANGED
|
@@ -7,10 +7,14 @@ class CrudFlow<D> {
|
|
|
7
7
|
private repository: mongoose.Model<any>
|
|
8
8
|
private search: any
|
|
9
9
|
|
|
10
|
-
constructor(repository: mongoose.Model<any>, search
|
|
10
|
+
constructor(repository: mongoose.Model<any>, search?: SearchFlow) {
|
|
11
11
|
this.repository = repository
|
|
12
12
|
this.search = search
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
public prepareSearch(search: SearchFlow) {
|
|
16
|
+
this.search = search
|
|
17
|
+
}
|
|
14
18
|
|
|
15
19
|
public async create(data: any, session: any = undefined) {
|
|
16
20
|
return await this.repository.create([data], { session })
|
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -10,7 +10,7 @@ abstract class SearchFlow {
|
|
|
10
10
|
page: number
|
|
11
11
|
limit: number
|
|
12
12
|
select: string
|
|
13
|
-
populate:
|
|
13
|
+
populate: any
|
|
14
14
|
filters: any
|
|
15
15
|
|
|
16
16
|
constructor(params: any) {
|
|
@@ -27,8 +27,10 @@ abstract class SearchFlow {
|
|
|
27
27
|
public buildPopulate(): any {
|
|
28
28
|
if (isEmpty(this.populate)) {
|
|
29
29
|
return
|
|
30
|
-
}
|
|
31
|
-
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var populateStr = this.populate as string
|
|
33
|
+
var propertiesArray = populateStr.split(',')
|
|
32
34
|
var populates = [] as any
|
|
33
35
|
for (var property of propertiesArray) {
|
|
34
36
|
let [first, ...rest] = property.split('.')
|