c2-mongoose 2.1.44 → 2.1.46
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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import mongoose, { ClientSession } from "mongoose";
|
|
2
2
|
import { SearchResponse } from "../types/SearchResponse";
|
|
3
3
|
import SearchFlow from "./SearchFlow";
|
|
4
|
+
export interface PipelineStage {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
4
7
|
declare class CrudFlow<D> {
|
|
5
8
|
private repository;
|
|
6
9
|
private search;
|
|
@@ -12,7 +15,7 @@ declare class CrudFlow<D> {
|
|
|
12
15
|
update(id: string, data: D, session?: any): Promise<D>;
|
|
13
16
|
updateAny(id: string, data: any, session?: any): Promise<D>;
|
|
14
17
|
updateByModel(filter: any, data: any, params: any): Promise<D>;
|
|
15
|
-
find(...
|
|
18
|
+
find(...pipelineStages: PipelineStage[]): Promise<SearchResponse<D>>;
|
|
16
19
|
getOne(model: D, params?: any): Promise<D>;
|
|
17
20
|
get(id: string, pop?: string, sel?: string, session?: ClientSession): Promise<D>;
|
|
18
21
|
getById(id: string, session?: ClientSession): Promise<Partial<D>>;
|
package/dist/flow/CrudFlow.js
CHANGED
|
@@ -124,14 +124,14 @@ var CrudFlow = /** @class */ (function () {
|
|
|
124
124
|
});
|
|
125
125
|
};
|
|
126
126
|
CrudFlow.prototype.find = function () {
|
|
127
|
-
var
|
|
127
|
+
var pipelineStages = [];
|
|
128
128
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
129
|
-
|
|
129
|
+
pipelineStages[_i] = arguments[_i];
|
|
130
130
|
}
|
|
131
131
|
return __awaiter(this, void 0, void 0, function () {
|
|
132
132
|
return __generator(this, function (_a) {
|
|
133
133
|
switch (_a.label) {
|
|
134
|
-
case 0: return [4 /*yield*/, this.search.search(this.repository,
|
|
134
|
+
case 0: return [4 /*yield*/, this.search.search(this.repository, pipelineStages)];
|
|
135
135
|
case 1: return [2 /*return*/, _a.sent()];
|
|
136
136
|
}
|
|
137
137
|
});
|
|
@@ -17,7 +17,7 @@ declare abstract class SearchFlow {
|
|
|
17
17
|
buildOrdenation(): any;
|
|
18
18
|
diacriticSensitiveRegex(string?: string): string;
|
|
19
19
|
searchPageable(model: mongoose.Model<any>, pipeline: any): Promise<any>;
|
|
20
|
-
search(model: mongoose.Model<any>, pipeline
|
|
20
|
+
search(model: mongoose.Model<any>, pipeline?: any): Promise<SearchResponse<any>>;
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @param model
|
package/package.json
CHANGED
package/src/flow/CrudFlow.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { SearchResponse } from "../types/SearchResponse"
|
|
|
3
3
|
import SearchFlow from "./SearchFlow"
|
|
4
4
|
import { isEmpty, isNotEmpty } from "../utils/Utils"
|
|
5
5
|
|
|
6
|
+
export interface PipelineStage {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
6
9
|
class CrudFlow<D> {
|
|
7
10
|
|
|
8
11
|
private repository: mongoose.Model<any>
|
|
@@ -44,8 +47,8 @@ class CrudFlow<D> {
|
|
|
44
47
|
return dataAfter as D
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
public async find(...
|
|
48
|
-
return await this.search.search(this.repository,
|
|
50
|
+
public async find(...pipelineStages: PipelineStage[]): Promise<SearchResponse<D>> {
|
|
51
|
+
return await this.search.search(this.repository, pipelineStages)
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
public async getOne(model: D, params: any = {}): Promise<D> {
|
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -104,7 +104,7 @@ abstract class SearchFlow {
|
|
|
104
104
|
return result[0]
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
public async search(model: mongoose.Model<any>, pipeline
|
|
107
|
+
public async search(model: mongoose.Model<any>, pipeline?: any): Promise<SearchResponse<any>> {
|
|
108
108
|
if (this.pageable == true) {
|
|
109
109
|
if (pipeline) {
|
|
110
110
|
return await this.searchPageable(model, pipeline)
|