c2-mongoose 2.1.75 → 2.1.77
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/SearchFlow.js
CHANGED
|
@@ -60,6 +60,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
60
60
|
};
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
62
|
var moment_1 = __importDefault(require("moment"));
|
|
63
|
+
var mongoose_1 = require("mongoose");
|
|
63
64
|
var Environment_1 = require("../configuration/Environment");
|
|
64
65
|
var Utils_1 = require("../utils/Utils");
|
|
65
66
|
var SearchFlow = /** @class */ (function () {
|
|
@@ -195,7 +196,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
195
196
|
stagesItems = __spreadArray([
|
|
196
197
|
{ $match: this.filters },
|
|
197
198
|
{ $sort: this.sort },
|
|
198
|
-
{ $skip: (this.page - 1) * this.limit },
|
|
199
|
+
{ $skip: ((this.page - 1) * this.limit) || 0 },
|
|
199
200
|
{ $limit: this.limit },
|
|
200
201
|
this.projection ? { $project: this.projection } : { $addFields: {} }
|
|
201
202
|
], options.pipelines, true);
|
|
@@ -208,7 +209,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
208
209
|
{ $count: "total" },
|
|
209
210
|
{
|
|
210
211
|
$addFields: {
|
|
211
|
-
page: this.page,
|
|
212
|
+
page: this.page || 1,
|
|
212
213
|
limit: this.limit
|
|
213
214
|
}
|
|
214
215
|
}
|
|
@@ -415,6 +416,9 @@ var SearchFlow = /** @class */ (function () {
|
|
|
415
416
|
if (['projection', 'pageable', 'order', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
416
417
|
return;
|
|
417
418
|
}
|
|
419
|
+
if (key.endsWith("_id")) {
|
|
420
|
+
value = new mongoose_1.Types.ObjectId(value);
|
|
421
|
+
}
|
|
418
422
|
if (value === 'true') {
|
|
419
423
|
value = true;
|
|
420
424
|
}
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import moment from "moment"
|
|
2
|
-
import mongoose, { ClientSession } from "mongoose"
|
|
2
|
+
import mongoose, { ClientSession, Types } from "mongoose"
|
|
3
3
|
import { dbCollation } from "../configuration/Environment"
|
|
4
4
|
import { Pagination, SearchOptions, SearchResponse } from "../types/SearchResponse"
|
|
5
5
|
import { isEmpty, isNotEmpty } from "../utils/Utils"
|
|
@@ -119,7 +119,7 @@ abstract class SearchFlow {
|
|
|
119
119
|
let stagesItems = [
|
|
120
120
|
{ $match: this.filters },
|
|
121
121
|
{ $sort: this.sort },
|
|
122
|
-
{ $skip: (this.page - 1) * this.limit },
|
|
122
|
+
{ $skip: ((this.page - 1) * this.limit) || 0 },
|
|
123
123
|
{ $limit: this.limit },
|
|
124
124
|
this.projection ? { $project: this.projection } : { $addFields: {} },
|
|
125
125
|
...options.pipelines
|
|
@@ -136,7 +136,7 @@ abstract class SearchFlow {
|
|
|
136
136
|
{
|
|
137
137
|
$addFields:
|
|
138
138
|
{
|
|
139
|
-
page: this.page,
|
|
139
|
+
page: this.page || 1,
|
|
140
140
|
limit: this.limit
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -309,6 +309,10 @@ abstract class SearchFlow {
|
|
|
309
309
|
return
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
+
if (key.endsWith("_id")) {
|
|
313
|
+
value = new Types.ObjectId(value as string)
|
|
314
|
+
}
|
|
315
|
+
|
|
312
316
|
if (value === 'true') {
|
|
313
317
|
value = true
|
|
314
318
|
}
|