c2-mongoose 2.0.3 → 2.0.5
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
|
@@ -7,7 +7,7 @@ declare class CrudFlow<D> extends SearchFlow {
|
|
|
7
7
|
delete: (id: string, session?: any) => Promise<void>;
|
|
8
8
|
update: (id: string, data: D, session?: any) => Promise<D>;
|
|
9
9
|
find: (search: SearchFlow) => Promise<SearchResponse<D>>;
|
|
10
|
-
getOne: (model: D,
|
|
10
|
+
getOne: (model: D, params?: any) => Promise<D>;
|
|
11
11
|
get: (id: string, pop?: string, sel?: string) => Promise<D>;
|
|
12
12
|
}
|
|
13
13
|
export default CrudFlow;
|
package/dist/flow/CrudFlow.js
CHANGED
|
@@ -106,13 +106,13 @@ var CrudFlow = /** @class */ (function (_super) {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
}); };
|
|
109
|
-
_this.getOne = function (model,
|
|
110
|
-
if (
|
|
109
|
+
_this.getOne = function (model, params) {
|
|
110
|
+
if (params === void 0) { params = {}; }
|
|
111
111
|
return __awaiter(_this, void 0, void 0, function () {
|
|
112
112
|
var data;
|
|
113
113
|
return __generator(this, function (_a) {
|
|
114
114
|
switch (_a.label) {
|
|
115
|
-
case 0: return [4 /*yield*/, _super.prototype.findOne.call(this, this.repository, model,
|
|
115
|
+
case 0: return [4 /*yield*/, _super.prototype.findOne.call(this, this.repository, model, params)];
|
|
116
116
|
case 1:
|
|
117
117
|
data = _a.sent();
|
|
118
118
|
return [2 /*return*/, data];
|
|
@@ -19,7 +19,7 @@ declare abstract class SearchFlow {
|
|
|
19
19
|
private searchNoPageable;
|
|
20
20
|
private result;
|
|
21
21
|
count: (model: mongoose.Model<any>) => Promise<number>;
|
|
22
|
-
findOne(repository: mongoose.Model<any>, model: any,
|
|
22
|
+
findOne(repository: mongoose.Model<any>, model: any, params?: any): Promise<any>;
|
|
23
23
|
sumBy: (model: mongoose.Model<any>, _sum: any, _by: any) => Promise<any[]>;
|
|
24
24
|
buildDefaultFilters: (objectSearch: any) => any;
|
|
25
25
|
addFilterModel: (model: any, filters: any) => void;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -260,13 +260,15 @@ var SearchFlow = /** @class */ (function () {
|
|
|
260
260
|
this.limit = params.limit || 25;
|
|
261
261
|
this.buildPopulate();
|
|
262
262
|
}
|
|
263
|
-
SearchFlow.prototype.findOne = function (repository, model,
|
|
264
|
-
if (
|
|
263
|
+
SearchFlow.prototype.findOne = function (repository, model, params) {
|
|
264
|
+
if (params === void 0) { params = {}; }
|
|
265
265
|
return __awaiter(this, void 0, void 0, function () {
|
|
266
266
|
return __generator(this, function (_a) {
|
|
267
267
|
switch (_a.label) {
|
|
268
268
|
case 0: return [4 /*yield*/, repository.findOne(model)
|
|
269
|
-
.sort(sort)
|
|
269
|
+
.sort(params.sort)
|
|
270
|
+
.select(params.select)
|
|
271
|
+
.populate(params.populate)];
|
|
270
272
|
case 1: return [2 /*return*/, _a.sent()];
|
|
271
273
|
}
|
|
272
274
|
});
|
package/package.json
CHANGED
package/src/flow/CrudFlow.ts
CHANGED
|
@@ -27,8 +27,8 @@ class CrudFlow<D> extends SearchFlow {
|
|
|
27
27
|
return await search.search(this.repository)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
public getOne = async (model: D,
|
|
31
|
-
const data = await super.findOne(this.repository, model,
|
|
30
|
+
public getOne = async (model: D, params: any = {}): Promise<D> => {
|
|
31
|
+
const data = await super.findOne(this.repository, model, params)
|
|
32
32
|
return data as D
|
|
33
33
|
}
|
|
34
34
|
|
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -133,9 +133,11 @@ abstract class SearchFlow {
|
|
|
133
133
|
return await model.countDocuments(this.filters).exec()
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
public async findOne(repository: mongoose.Model<any>, model: any,
|
|
136
|
+
public async findOne(repository: mongoose.Model<any>, model: any, params: any = {}) {
|
|
137
137
|
return await repository.findOne(model)
|
|
138
|
-
.sort(sort)
|
|
138
|
+
.sort(params.sort)
|
|
139
|
+
.select(params.select)
|
|
140
|
+
.populate(params.populate)
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
public sumBy = async (model: mongoose.Model<any>, _sum: any, _by: any): Promise<any[]> => {
|