c2-mongoose 2.1.152 → 2.1.153

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,9 @@ 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 { IFacet } from "./model/Facet";
6
7
  import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger";
7
8
  import { Options } from "./types/Options";
8
9
  import { Pagination, SearchResponse } from "./types/SearchResponse";
9
10
  import { initialize } from "./utils/Utils";
10
- export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem };
11
+ export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet };
@@ -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.153",
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,7 @@ 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 { IFacet } from "./model/Facet"
6
7
  import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger"
7
8
  import { Options } from "./types/Options"
8
9
  import { Pagination, SearchResponse } from "./types/SearchResponse"
@@ -12,6 +13,6 @@ import { initialize } from "./utils/Utils"
12
13
 
13
14
  export {
14
15
  C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize,
15
- BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem
16
+ BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet
16
17
  }
17
18
 
@@ -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 }