c2-mongoose 2.1.96 → 2.1.97
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
|
@@ -13,7 +13,7 @@ declare class CrudFlow<D> {
|
|
|
13
13
|
updateAny(id: string, data: any, session?: any): Promise<D>;
|
|
14
14
|
updateByModel(filter: any, data: any, params: any): Promise<D>;
|
|
15
15
|
find(options?: SearchOptions): Promise<SearchResponse<D>>;
|
|
16
|
-
getOne(model: D,
|
|
16
|
+
getOne(model: D, session: ClientSession): Promise<D>;
|
|
17
17
|
get(id: string, pop?: string, sel?: string, session?: ClientSession): Promise<D>;
|
|
18
18
|
getById(id: string, session?: ClientSession): Promise<Partial<D>>;
|
|
19
19
|
sumBy(fieldToSum: any, fieldToGroup: any, addToSet?: any, session?: ClientSession): Promise<any>;
|
package/dist/flow/CrudFlow.js
CHANGED
|
@@ -133,13 +133,12 @@ var CrudFlow = /** @class */ (function () {
|
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
};
|
|
136
|
-
CrudFlow.prototype.getOne = function (model,
|
|
137
|
-
if (params === void 0) { params = {}; }
|
|
136
|
+
CrudFlow.prototype.getOne = function (model, session) {
|
|
138
137
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
138
|
var data;
|
|
140
139
|
return __generator(this, function (_a) {
|
|
141
140
|
switch (_a.label) {
|
|
142
|
-
case 0: return [4 /*yield*/, this.search.findOne(this.repository, model,
|
|
141
|
+
case 0: return [4 /*yield*/, this.search.findOne(this.repository, model, session)];
|
|
143
142
|
case 1:
|
|
144
143
|
data = _a.sent();
|
|
145
144
|
return [2 /*return*/, data];
|
|
@@ -38,7 +38,7 @@ declare abstract class SearchFlow {
|
|
|
38
38
|
private searchNoPageable;
|
|
39
39
|
private result;
|
|
40
40
|
count(model: mongoose.Model<any>): Promise<number>;
|
|
41
|
-
findOne(repository: mongoose.Model<any>, model: any,
|
|
41
|
+
findOne(repository: mongoose.Model<any>, model: any, session?: ClientSession): Promise<any>;
|
|
42
42
|
sumBy(model: mongoose.Model<any>, _sum: any, _by: any, items?: any, session?: ClientSession): Promise<any[]>;
|
|
43
43
|
sumByPaging(model: mongoose.Model<any>, fieldToSum: any, fieldToGroup: any, items?: any): Promise<SearchResponse<any>>;
|
|
44
44
|
isValidObjectId(value: string): boolean;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -309,16 +309,15 @@ var SearchFlow = /** @class */ (function () {
|
|
|
309
309
|
});
|
|
310
310
|
});
|
|
311
311
|
};
|
|
312
|
-
SearchFlow.prototype.findOne = function (repository, model,
|
|
313
|
-
if (params === void 0) { params = {}; }
|
|
312
|
+
SearchFlow.prototype.findOne = function (repository, model, session) {
|
|
314
313
|
return __awaiter(this, void 0, void 0, function () {
|
|
315
314
|
return __generator(this, function (_a) {
|
|
316
315
|
switch (_a.label) {
|
|
317
316
|
case 0: return [4 /*yield*/, repository.findOne(model)
|
|
318
|
-
.sort(
|
|
319
|
-
.select(
|
|
320
|
-
.populate(
|
|
321
|
-
.session(
|
|
317
|
+
.sort(this.sort)
|
|
318
|
+
.select(this.select)
|
|
319
|
+
.populate(this.populate)
|
|
320
|
+
.session(session)];
|
|
322
321
|
case 1: return [2 /*return*/, _a.sent()];
|
|
323
322
|
}
|
|
324
323
|
});
|
package/package.json
CHANGED
package/src/flow/CrudFlow.ts
CHANGED
|
@@ -48,8 +48,8 @@ class CrudFlow<D> {
|
|
|
48
48
|
return await this.search.search(this.repository, options)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
public async getOne(model: D,
|
|
52
|
-
const data = await this.search.findOne(this.repository, model,
|
|
51
|
+
public async getOne(model: D, session: ClientSession): Promise<D> {
|
|
52
|
+
const data = await this.search.findOne(this.repository, model, session)
|
|
53
53
|
return data as D
|
|
54
54
|
}
|
|
55
55
|
|
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -247,12 +247,12 @@ abstract class SearchFlow {
|
|
|
247
247
|
return await model.countDocuments(this.filters).exec()
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
public async findOne(repository: mongoose.Model<any>, model: any,
|
|
250
|
+
public async findOne(repository: mongoose.Model<any>, model: any, session?: ClientSession) {
|
|
251
251
|
return await repository.findOne(model)
|
|
252
|
-
.sort(
|
|
253
|
-
.select(
|
|
254
|
-
.populate(
|
|
255
|
-
.session(
|
|
252
|
+
.sort(this.sort)
|
|
253
|
+
.select(this.select)
|
|
254
|
+
.populate(this.populate)
|
|
255
|
+
.session(session!)
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
public async sumBy(model: mongoose.Model<any>, _sum: any, _by: any, items: any = undefined, session?: ClientSession): Promise<any[]> {
|