c2-mongoose 2.1.176 → 2.1.178
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.
|
@@ -2,7 +2,7 @@ import mongoose, { ClientSession } from "mongoose";
|
|
|
2
2
|
import { SearchOptions, SearchResponse } from "../types/SearchResponse";
|
|
3
3
|
declare abstract class SearchFlow {
|
|
4
4
|
searchText: string;
|
|
5
|
-
|
|
5
|
+
orderSense: string;
|
|
6
6
|
orderBy: string;
|
|
7
7
|
page: number;
|
|
8
8
|
limit: number;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -56,7 +56,7 @@ var Utils_1 = require("../utils/Utils");
|
|
|
56
56
|
var SearchFlow = /** @class */ (function () {
|
|
57
57
|
function SearchFlow(params) {
|
|
58
58
|
this.searchText = params.searchText || "";
|
|
59
|
-
this.
|
|
59
|
+
this.orderSense = params.order || "asc";
|
|
60
60
|
this.orderBy = params.orderBy || "_id";
|
|
61
61
|
this.select = params.select;
|
|
62
62
|
this.populate = params.populate;
|
|
@@ -132,7 +132,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
132
132
|
SearchFlow.prototype.buildOrdenation = function () {
|
|
133
133
|
var order = {};
|
|
134
134
|
this.orderBy = this.orderBy || "_id";
|
|
135
|
-
order[this.orderBy] = this.
|
|
135
|
+
order[this.orderBy] = this.orderSense === "desc" ? -1 : 1;
|
|
136
136
|
this.sort = order;
|
|
137
137
|
return order;
|
|
138
138
|
};
|
|
@@ -189,6 +189,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
189
189
|
], {
|
|
190
190
|
collation: {
|
|
191
191
|
locale: "pt",
|
|
192
|
+
numericOrdering: true
|
|
192
193
|
}
|
|
193
194
|
}).session(options === null || options === void 0 ? void 0 : options.session)];
|
|
194
195
|
case 1:
|
|
@@ -268,6 +269,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
268
269
|
], {
|
|
269
270
|
collation: {
|
|
270
271
|
locale: "pt",
|
|
272
|
+
numericOrdering: true
|
|
271
273
|
}
|
|
272
274
|
}).session(options === null || options === void 0 ? void 0 : options.session)];
|
|
273
275
|
case 1:
|
|
@@ -440,7 +442,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
440
442
|
var key = _a[0], value = _a[1];
|
|
441
443
|
if ((0, Utils_1.isNotEmpty)(value)) {
|
|
442
444
|
var condition = {};
|
|
443
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
445
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
444
446
|
return;
|
|
445
447
|
}
|
|
446
448
|
if (typeof value === 'string' && _this.isValidObjectId(value)) {
|
|
@@ -514,7 +516,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
514
516
|
if (key.endsWith('Like')) {
|
|
515
517
|
return;
|
|
516
518
|
}
|
|
517
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
519
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
518
520
|
return;
|
|
519
521
|
}
|
|
520
522
|
if ((0, Utils_1.isNotEmpty)(value)) {
|
|
@@ -7,7 +7,7 @@ var GetStageSortFlowItem = /** @class */ (function () {
|
|
|
7
7
|
var _a;
|
|
8
8
|
if (facet === void 0) { facet = { items: [] }; }
|
|
9
9
|
var facetAfter = facet;
|
|
10
|
-
var sortByDirection = searcher.
|
|
10
|
+
var sortByDirection = searcher.orderSense === "desc" ? -1 : 1;
|
|
11
11
|
var sortByField = searcher.orderBy || "_id";
|
|
12
12
|
facetAfter.items.push({ $sort: (_a = {}, _a["".concat(sortByField)] = sortByDirection, _a) });
|
|
13
13
|
facet = facetAfter;
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { isEmpty, isNotEmpty } from "../utils/Utils"
|
|
|
5
5
|
|
|
6
6
|
abstract class SearchFlow {
|
|
7
7
|
searchText: string
|
|
8
|
-
|
|
8
|
+
orderSense: string
|
|
9
9
|
orderBy: string
|
|
10
10
|
page: number
|
|
11
11
|
limit: number
|
|
@@ -19,7 +19,7 @@ abstract class SearchFlow {
|
|
|
19
19
|
|
|
20
20
|
constructor(params: any) {
|
|
21
21
|
this.searchText = params.searchText || ""
|
|
22
|
-
this.
|
|
22
|
+
this.orderSense = params.order || "asc"
|
|
23
23
|
this.orderBy = params.orderBy || "_id"
|
|
24
24
|
this.select = params.select
|
|
25
25
|
this.populate = params.populate
|
|
@@ -106,7 +106,7 @@ abstract class SearchFlow {
|
|
|
106
106
|
public buildOrdenation() {
|
|
107
107
|
let order = {} as any
|
|
108
108
|
this.orderBy = this.orderBy || "_id"
|
|
109
|
-
order[this.orderBy] = this.
|
|
109
|
+
order[this.orderBy] = this.orderSense === "desc" ? -1 : 1
|
|
110
110
|
this.sort = order
|
|
111
111
|
return order
|
|
112
112
|
}
|
|
@@ -170,6 +170,7 @@ abstract class SearchFlow {
|
|
|
170
170
|
], {
|
|
171
171
|
collation: {
|
|
172
172
|
locale: "pt",
|
|
173
|
+
numericOrdering: true
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
).session(options?.session as ClientSession)
|
|
@@ -245,6 +246,7 @@ abstract class SearchFlow {
|
|
|
245
246
|
], {
|
|
246
247
|
collation: {
|
|
247
248
|
locale: "pt",
|
|
249
|
+
numericOrdering: true
|
|
248
250
|
}
|
|
249
251
|
}).session(options?.session as ClientSession)
|
|
250
252
|
|
|
@@ -379,7 +381,7 @@ abstract class SearchFlow {
|
|
|
379
381
|
Object.entries(objectSearch.model).forEach(([key, value]) => {
|
|
380
382
|
if (isNotEmpty(value)) {
|
|
381
383
|
let condition = {} as any
|
|
382
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
384
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
383
385
|
return
|
|
384
386
|
}
|
|
385
387
|
|
|
@@ -463,7 +465,7 @@ abstract class SearchFlow {
|
|
|
463
465
|
if (key.endsWith('Like')) {
|
|
464
466
|
return
|
|
465
467
|
}
|
|
466
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
468
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
467
469
|
return
|
|
468
470
|
}
|
|
469
471
|
if (isNotEmpty(value)) {
|
|
@@ -6,7 +6,7 @@ class GetStageSortFlowItem {
|
|
|
6
6
|
add(facet: IFacet = { items: [] }, searcher: SearchFlow): IFacet {
|
|
7
7
|
let facetAfter: IFacet = facet
|
|
8
8
|
|
|
9
|
-
let sortByDirection = searcher.
|
|
9
|
+
let sortByDirection = searcher.orderSense === "desc" ? -1 : 1
|
|
10
10
|
let sortByField = searcher.orderBy || "_id"
|
|
11
11
|
|
|
12
12
|
facetAfter.items.push({ $sort: { [`${sortByField}`]: sortByDirection } })
|