c2-mongoose 2.1.159 → 2.1.161

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.
@@ -0,0 +1,7 @@
1
+ import { IFacet } from "../../model/Facet";
2
+ import SearchFlow from "../SearchFlow";
3
+ declare class GetStagePaginationFlowItem {
4
+ get(facet: IFacet | undefined, searcher: SearchFlow): IFacet;
5
+ }
6
+ declare const _default: GetStagePaginationFlowItem;
7
+ export default _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var GetStagePaginationFlowItem = /** @class */ (function () {
4
+ function GetStagePaginationFlowItem() {
5
+ }
6
+ GetStagePaginationFlowItem.prototype.get = function (facet, searcher) {
7
+ if (facet === void 0) { facet = { items: [] }; }
8
+ var facetAfter = facet;
9
+ if (searcher.pageable === false) {
10
+ return facetAfter;
11
+ }
12
+ facetAfter.items.push({ $skip: ((searcher.page - 1) * searcher.limit) });
13
+ facetAfter.items.push({ $limit: searcher.limit });
14
+ facetAfter.paging = [
15
+ { $count: "total" },
16
+ { $addFields: { page: searcher.page || 1, limit: searcher.limit } }
17
+ ];
18
+ facet = facetAfter;
19
+ return facetAfter;
20
+ };
21
+ return GetStagePaginationFlowItem;
22
+ }());
23
+ exports.default = new GetStagePaginationFlowItem;
@@ -0,0 +1,7 @@
1
+ import { IFacet } from "../../model/Facet";
2
+ import SearchFlow from "../SearchFlow";
3
+ declare class GetStageSortFlowItem {
4
+ get(facet: IFacet | undefined, searcher: SearchFlow): IFacet;
5
+ }
6
+ declare const _default: GetStageSortFlowItem;
7
+ export default _default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var GetStageSortFlowItem = /** @class */ (function () {
4
+ function GetStageSortFlowItem() {
5
+ }
6
+ GetStageSortFlowItem.prototype.get = function (facet, searcher) {
7
+ var _a;
8
+ if (facet === void 0) { facet = { items: [] }; }
9
+ var facetAfter = facet;
10
+ var sortByDirection = searcher.order === "desc" ? -1 : 1;
11
+ var sortByField = searcher.orderBy || "_id";
12
+ facetAfter.items.push({ $sort: (_a = {}, _a["".concat(sortByField)] = sortByDirection, _a) });
13
+ facet = facetAfter;
14
+ return facetAfter;
15
+ };
16
+ return GetStageSortFlowItem;
17
+ }());
18
+ exports.default = new GetStageSortFlowItem;
package/dist/index.d.ts CHANGED
@@ -3,11 +3,11 @@ import CrudFlow from "./flow/CrudFlow";
3
3
  import SearchFlow from "./flow/SearchFlow";
4
4
  import BuildPipelineToCountJoinFlowItem from "./flow/item/BuildPipelineToCountJoinFlowItem";
5
5
  import BuildPipelineToJoinFlowItem from "./flow/item/BuildPipelineToJoinFlowItem";
6
- import GetStagePaginationFlowItem from "./flow/item/GetStagePaginationFlowItem";
7
- import GetStageSortFlowItem from "./flow/item/GetStageSortFlowItem";
6
+ import AddStagePaginationFlowItem from "./flow/item/AddStagePaginationFlowItem";
7
+ import AddStageSortFlowItem from "./flow/item/AddStageSortFlowItem";
8
8
  import { IFacet } from "./model/Facet";
9
9
  import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger";
10
10
  import { Options } from "./types/Options";
11
11
  import { Pagination, SearchResponse } from "./types/SearchResponse";
12
12
  import { initialize } from "./utils/Utils";
13
- export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet, GetStagePaginationFlowItem, GetStageSortFlowItem };
13
+ export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet, AddStagePaginationFlowItem, AddStageSortFlowItem };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GetStageSortFlowItem = exports.GetStagePaginationFlowItem = exports.BuildPipelineToJoinFlowItem = exports.BuildPipelineToCountJoinFlowItem = exports.initialize = exports.TypeOfOperation = exports.SearchFlow = exports.LoggerSearch = exports.LoggerModel = exports.CrudFlow = exports.C2Flow = void 0;
6
+ exports.AddStageSortFlowItem = exports.AddStagePaginationFlowItem = exports.BuildPipelineToJoinFlowItem = exports.BuildPipelineToCountJoinFlowItem = exports.initialize = exports.TypeOfOperation = exports.SearchFlow = exports.LoggerSearch = exports.LoggerModel = exports.CrudFlow = exports.C2Flow = void 0;
7
7
  var C2Flow_1 = __importDefault(require("./flow/C2Flow"));
8
8
  exports.C2Flow = C2Flow_1.default;
9
9
  var CrudFlow_1 = __importDefault(require("./flow/CrudFlow"));
@@ -14,10 +14,10 @@ var BuildPipelineToCountJoinFlowItem_1 = __importDefault(require("./flow/item/Bu
14
14
  exports.BuildPipelineToCountJoinFlowItem = BuildPipelineToCountJoinFlowItem_1.default;
15
15
  var BuildPipelineToJoinFlowItem_1 = __importDefault(require("./flow/item/BuildPipelineToJoinFlowItem"));
16
16
  exports.BuildPipelineToJoinFlowItem = BuildPipelineToJoinFlowItem_1.default;
17
- var GetStagePaginationFlowItem_1 = __importDefault(require("./flow/item/GetStagePaginationFlowItem"));
18
- exports.GetStagePaginationFlowItem = GetStagePaginationFlowItem_1.default;
19
- var GetStageSortFlowItem_1 = __importDefault(require("./flow/item/GetStageSortFlowItem"));
20
- exports.GetStageSortFlowItem = GetStageSortFlowItem_1.default;
17
+ var AddStagePaginationFlowItem_1 = __importDefault(require("./flow/item/AddStagePaginationFlowItem"));
18
+ exports.AddStagePaginationFlowItem = AddStagePaginationFlowItem_1.default;
19
+ var AddStageSortFlowItem_1 = __importDefault(require("./flow/item/AddStageSortFlowItem"));
20
+ exports.AddStageSortFlowItem = AddStageSortFlowItem_1.default;
21
21
  var Logger_1 = require("./model/Logger");
22
22
  Object.defineProperty(exports, "LoggerModel", { enumerable: true, get: function () { return Logger_1.LoggerModel; } });
23
23
  Object.defineProperty(exports, "LoggerSearch", { enumerable: true, get: function () { return Logger_1.LoggerSearch; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.159",
3
+ "version": "2.1.161",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,7 +17,7 @@ class GetStagePaginationFlowItem {
17
17
  { $count: "total" },
18
18
  { $addFields: { page: searcher.page || 1, limit: searcher.limit } }
19
19
  ]
20
-
20
+ facet = facetAfter
21
21
  return facetAfter
22
22
  }
23
23
  }
@@ -11,6 +11,7 @@ class GetStageSortFlowItem {
11
11
 
12
12
  facetAfter.items.push({ $sort: { [`${sortByField}`]: sortByDirection } })
13
13
 
14
+ facet = facetAfter
14
15
  return facetAfter
15
16
  }
16
17
  }
package/src/index.ts CHANGED
@@ -3,8 +3,8 @@ import CrudFlow from "./flow/CrudFlow"
3
3
  import SearchFlow from "./flow/SearchFlow"
4
4
  import BuildPipelineToCountJoinFlowItem from "./flow/item/BuildPipelineToCountJoinFlowItem"
5
5
  import BuildPipelineToJoinFlowItem from "./flow/item/BuildPipelineToJoinFlowItem"
6
- import GetStagePaginationFlowItem from "./flow/item/GetStagePaginationFlowItem"
7
- import GetStageSortFlowItem from "./flow/item/GetStageSortFlowItem"
6
+ import AddStagePaginationFlowItem from "./flow/item/AddStagePaginationFlowItem"
7
+ import AddStageSortFlowItem from "./flow/item/AddStageSortFlowItem"
8
8
  import { IFacet } from "./model/Facet"
9
9
  import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger"
10
10
  import { Options } from "./types/Options"
@@ -15,6 +15,6 @@ import { initialize } from "./utils/Utils"
15
15
 
16
16
  export {
17
17
  C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize,
18
- BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet, GetStagePaginationFlowItem, GetStageSortFlowItem
18
+ BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet, AddStagePaginationFlowItem, AddStageSortFlowItem
19
19
  }
20
20