c2-mongoose 2.1.152 → 2.1.154

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, searcher: SearchFlow): IFacet;
5
+ }
6
+ declare const _default: GetStagePaginationFlowItem;
7
+ export default _default;
@@ -0,0 +1,20 @@
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
+ var facetAfter = facet;
8
+ if (searcher.pageable === true) {
9
+ facetAfter.items.push({ $skip: ((searcher.page - 1) * searcher.limit) || 0 });
10
+ facetAfter.items.push({ $limit: searcher.limit });
11
+ facetAfter.paging = [
12
+ { $count: "total" },
13
+ { $addFields: { page: searcher.page || 1, limit: searcher.limit } }
14
+ ];
15
+ }
16
+ return facetAfter;
17
+ };
18
+ return GetStagePaginationFlowItem;
19
+ }());
20
+ exports.default = new GetStagePaginationFlowItem;
package/dist/index.d.ts CHANGED
@@ -3,8 +3,10 @@ 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 { IFacet } from "./model/Facet";
6
8
  import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger";
7
9
  import { Options } from "./types/Options";
8
10
  import { Pagination, SearchResponse } from "./types/SearchResponse";
9
11
  import { initialize } from "./utils/Utils";
10
- export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem };
12
+ export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet, GetStagePaginationFlowItem };
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.BuildPipelineToJoinFlowItem = exports.BuildPipelineToCountJoinFlowItem = exports.initialize = exports.TypeOfOperation = exports.SearchFlow = exports.LoggerSearch = exports.LoggerModel = exports.CrudFlow = exports.C2Flow = void 0;
6
+ exports.GetStagePaginationFlowItem = 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,6 +14,8 @@ 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;
17
19
  var Logger_1 = require("./model/Logger");
18
20
  Object.defineProperty(exports, "LoggerModel", { enumerable: true, get: function () { return Logger_1.LoggerModel; } });
19
21
  Object.defineProperty(exports, "LoggerSearch", { enumerable: true, get: function () { return Logger_1.LoggerSearch; } });
@@ -0,0 +1,13 @@
1
+ interface IFacet {
2
+ items: {
3
+ [key: string]: any;
4
+ $skip?: number;
5
+ $limit?: number;
6
+ }[];
7
+ paging?: {
8
+ [key: string]: any;
9
+ $count?: string;
10
+ $addFields?: {};
11
+ }[];
12
+ }
13
+ export { IFacet };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.152",
3
+ "version": "2.1.154",
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",
@@ -0,0 +1,23 @@
1
+ import { IFacet } from "../../model/Facet"
2
+ import SearchFlow from "../SearchFlow"
3
+
4
+ class GetStagePaginationFlowItem {
5
+
6
+ get(facet: IFacet, searcher: SearchFlow): IFacet {
7
+ let facetAfter: IFacet = facet
8
+
9
+ if (searcher.pageable === true) {
10
+ facetAfter.items.push({ $skip: ((searcher.page - 1) * searcher.limit) || 0 })
11
+ facetAfter.items.push({ $limit: searcher.limit })
12
+
13
+ facetAfter.paging = [
14
+ { $count: "total" },
15
+ { $addFields: { page: searcher.page || 1, limit: searcher.limit } }
16
+ ]
17
+ }
18
+
19
+ return facetAfter
20
+ }
21
+ }
22
+
23
+ export default new GetStagePaginationFlowItem
package/src/index.ts CHANGED
@@ -3,6 +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 { IFacet } from "./model/Facet"
6
8
  import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger"
7
9
  import { Options } from "./types/Options"
8
10
  import { Pagination, SearchResponse } from "./types/SearchResponse"
@@ -12,6 +14,6 @@ import { initialize } from "./utils/Utils"
12
14
 
13
15
  export {
14
16
  C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize,
15
- BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem
17
+ BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet, GetStagePaginationFlowItem
16
18
  }
17
19
 
@@ -0,0 +1,15 @@
1
+ interface IFacet {
2
+ items: {
3
+ [key: string]: any,
4
+ $skip?: number,
5
+ $limit?: number,
6
+ }[],
7
+ paging?: {
8
+ [key: string]: any,
9
+ $count?: string,
10
+ $addFields?: {}
11
+ }[]
12
+ }
13
+
14
+
15
+ export { IFacet }