c2-mongoose 2.0.4 → 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,14 +106,13 @@ var CrudFlow = /** @class */ (function (_super) {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
}); };
|
|
109
|
-
_this.getOne = function (model,
|
|
110
|
-
if (
|
|
111
|
-
if (sort === void 0) { sort = undefined; }
|
|
109
|
+
_this.getOne = function (model, params) {
|
|
110
|
+
if (params === void 0) { params = {}; }
|
|
112
111
|
return __awaiter(_this, void 0, void 0, function () {
|
|
113
112
|
var data;
|
|
114
113
|
return __generator(this, function (_a) {
|
|
115
114
|
switch (_a.label) {
|
|
116
|
-
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)];
|
|
117
116
|
case 1:
|
|
118
117
|
data = _a.sent();
|
|
119
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,16 +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 (
|
|
265
|
-
if (sort === void 0) { sort = undefined; }
|
|
263
|
+
SearchFlow.prototype.findOne = function (repository, model, params) {
|
|
264
|
+
if (params === void 0) { params = {}; }
|
|
266
265
|
return __awaiter(this, void 0, void 0, function () {
|
|
267
266
|
return __generator(this, function (_a) {
|
|
268
267
|
switch (_a.label) {
|
|
269
268
|
case 0: return [4 /*yield*/, repository.findOne(model)
|
|
270
|
-
.sort(sort)
|
|
271
|
-
.select(select)
|
|
272
|
-
.populate(populate)];
|
|
269
|
+
.sort(params.sort)
|
|
270
|
+
.select(params.select)
|
|
271
|
+
.populate(params.populate)];
|
|
273
272
|
case 1: return [2 /*return*/, _a.sent()];
|
|
274
273
|
}
|
|
275
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,11 +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)
|
|
139
|
-
.select(select)
|
|
140
|
-
.populate(populate)
|
|
138
|
+
.sort(params.sort)
|
|
139
|
+
.select(params.select)
|
|
140
|
+
.populate(params.populate)
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
public sumBy = async (model: mongoose.Model<any>, _sum: any, _by: any): Promise<any[]> => {
|