c2-mongoose 2.1.177 → 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
|
};
|
|
@@ -442,7 +442,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
442
442
|
var key = _a[0], value = _a[1];
|
|
443
443
|
if ((0, Utils_1.isNotEmpty)(value)) {
|
|
444
444
|
var condition = {};
|
|
445
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
445
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
446
446
|
return;
|
|
447
447
|
}
|
|
448
448
|
if (typeof value === 'string' && _this.isValidObjectId(value)) {
|
|
@@ -516,7 +516,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
516
516
|
if (key.endsWith('Like')) {
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
519
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
520
520
|
return;
|
|
521
521
|
}
|
|
522
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
|
}
|
|
@@ -381,7 +381,7 @@ abstract class SearchFlow {
|
|
|
381
381
|
Object.entries(objectSearch.model).forEach(([key, value]) => {
|
|
382
382
|
if (isNotEmpty(value)) {
|
|
383
383
|
let condition = {} as any
|
|
384
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
384
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
385
385
|
return
|
|
386
386
|
}
|
|
387
387
|
|
|
@@ -465,7 +465,7 @@ abstract class SearchFlow {
|
|
|
465
465
|
if (key.endsWith('Like')) {
|
|
466
466
|
return
|
|
467
467
|
}
|
|
468
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
468
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
469
469
|
return
|
|
470
470
|
}
|
|
471
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 } })
|