c2-mongoose 2.1.177 → 2.1.179
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import mongoose, { ClientSession } from "mongoose";
|
|
2
2
|
import { SearchOptions, SearchResponse } from "../types/SearchResponse";
|
|
3
3
|
declare abstract class SearchFlow {
|
|
4
|
+
[key: string]: any;
|
|
4
5
|
searchText: string;
|
|
5
|
-
|
|
6
|
+
orderSense: string;
|
|
6
7
|
orderBy: string;
|
|
7
8
|
page: number;
|
|
8
9
|
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
|
};
|
|
@@ -438,11 +438,11 @@ var SearchFlow = /** @class */ (function () {
|
|
|
438
438
|
SearchFlow.prototype.buildDefaultFilters = function (objectSearch) {
|
|
439
439
|
var _this = this;
|
|
440
440
|
var filters = { $and: [] };
|
|
441
|
-
Object.entries(objectSearch
|
|
441
|
+
Object.entries(objectSearch).forEach(function (_a) {
|
|
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
|
@@ -4,8 +4,9 @@ import { SearchOptions, SearchResponse } from "../types/SearchResponse"
|
|
|
4
4
|
import { isEmpty, isNotEmpty } from "../utils/Utils"
|
|
5
5
|
|
|
6
6
|
abstract class SearchFlow {
|
|
7
|
+
[key: string]: any
|
|
7
8
|
searchText: string
|
|
8
|
-
|
|
9
|
+
orderSense: string
|
|
9
10
|
orderBy: string
|
|
10
11
|
page: number
|
|
11
12
|
limit: number
|
|
@@ -19,7 +20,7 @@ abstract class SearchFlow {
|
|
|
19
20
|
|
|
20
21
|
constructor(params: any) {
|
|
21
22
|
this.searchText = params.searchText || ""
|
|
22
|
-
this.
|
|
23
|
+
this.orderSense = params.order || "asc"
|
|
23
24
|
this.orderBy = params.orderBy || "_id"
|
|
24
25
|
this.select = params.select
|
|
25
26
|
this.populate = params.populate
|
|
@@ -106,7 +107,7 @@ abstract class SearchFlow {
|
|
|
106
107
|
public buildOrdenation() {
|
|
107
108
|
let order = {} as any
|
|
108
109
|
this.orderBy = this.orderBy || "_id"
|
|
109
|
-
order[this.orderBy] = this.
|
|
110
|
+
order[this.orderBy] = this.orderSense === "desc" ? -1 : 1
|
|
110
111
|
this.sort = order
|
|
111
112
|
return order
|
|
112
113
|
}
|
|
@@ -378,10 +379,10 @@ abstract class SearchFlow {
|
|
|
378
379
|
|
|
379
380
|
public buildDefaultFilters(objectSearch: any) {
|
|
380
381
|
let filters = { $and: [] } as any
|
|
381
|
-
Object.entries(objectSearch
|
|
382
|
+
Object.entries(objectSearch).forEach(([key, value]) => {
|
|
382
383
|
if (isNotEmpty(value)) {
|
|
383
384
|
let condition = {} as any
|
|
384
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
385
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
385
386
|
return
|
|
386
387
|
}
|
|
387
388
|
|
|
@@ -465,7 +466,7 @@ abstract class SearchFlow {
|
|
|
465
466
|
if (key.endsWith('Like')) {
|
|
466
467
|
return
|
|
467
468
|
}
|
|
468
|
-
if (['onlyMetadata', 'projection', 'pageable', '
|
|
469
|
+
if (['onlyMetadata', 'projection', 'pageable', 'orderSense', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'select', 'searchText', 'isPageable', 'searchPageable'].includes(key)) {
|
|
469
470
|
return
|
|
470
471
|
}
|
|
471
472
|
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 } })
|