@r5v/mongoose-paginate 1.0.11 → 1.0.12

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.
package/README.md CHANGED
@@ -89,9 +89,11 @@ PagingQuery(Express.Request, mongoose.Model, options )
89
89
  | Key | Value | Description | Class Availability | Required | Default |
90
90
  |:----------------------------|:---------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------|:---------|:--------|
91
91
  | disablePaging | boolean | disables paging and $paging param use | PagingQuery, AggregationPagingQuery | | false |
92
- | enableFilter | boolean | disables the $filter param on req. | PagingQuery, AggregationPagingQuery | | false |
93
- | single | boolean | disables paging on the query. converts from .find query to .findOne() | PagingQuery, AggregationPagingQuery | | true |
94
- | enablePostFilter | boolean | disables the ability to create a dynamic filter per request | AggregationPagingQuery | | false |
92
+ | disableFilter | boolean | disables the $filter param on req. | PagingQuery | | false |
93
+ | enableFilter | boolean | enables the $filter param on req for aggregation queries. | AggregationPagingQuery | | false |
94
+ | enablePreSort | boolean | enables the $preSort param on req for aggregation queries. | AggregationPagingQuery | | false |
95
+ | single | boolean | disables paging on the query. converts from .find query to .findOne() | PagingQuery | | false |
96
+ | enablePostFilter | boolean | enables the ability to create a dynamic filter per request using the $postFilter parameter | AggregationPagingQuery | | false |
95
97
  | staticPostFilter | Mongo Filter Object | create a filter on the pipeline that is added after all the pipeline stages. this cannot be overwritten by params | AggregationPagingQuery | | {} |
96
98
  | staticFilter | Mongo Filter Object | create a filter on the pipeline that is added before all the pipeline stages. on find requests, this is added to the filter object. this cannot be overwritten by params | AggregationPagingQuery | | {} |
97
99
  | pipeline | MongoPipelineStage[] | pipeline request object. if the first item in pipeline stage is a $match or another required first stage operator. it will be placed before all other modifiers | AggregationPagingQuery | true | [] |
@@ -134,6 +136,11 @@ $ yarn run start
134
136
  ## NOTES
135
137
  1. removeProtected removed from aggregation query due to inconsistent results after publication
136
138
 
139
+ ### 1.0.12
140
+ - Fix issue with AggregationPagingQuery where static post filter would not be applied if $postFilter param was not supplied
141
+ - updated typings on AggregationPagingQuery to include enablePostFilter, enableFilter, and enablePreSort
142
+ - flipped PagingQuery back to `disableFilter` instead of `enableFilter` option \# this was set incorrectly in 1.0.11 but still defaults to false
143
+
137
144
  ### 1.0.11
138
145
  Fix Issue with Typescript build
139
146
 
@@ -91,7 +91,7 @@ class AggregationPagingQuery {
91
91
  if (Object.keys(typeCastFilter).length !== 0) {
92
92
  this.query.match(typeCastFilter);
93
93
  }
94
- if (this.options.enablePresort && Object.keys($preSort).length) {
94
+ if (this.options.enablePreSort && Object.keys($preSort).length) {
95
95
  this.query.sort($preSort);
96
96
  }
97
97
  if (!firstObj) {
@@ -104,7 +104,7 @@ class AggregationPagingQuery {
104
104
  if ($count.length) {
105
105
  this.createCounts();
106
106
  }
107
- if (Object.keys($postFilter).length !== 0) {
107
+ if ((Object.keys($postFilter).length !== 0 && enablePostFilter) || staticPostFilter !== undefined) {
108
108
  this.query.match(typeCastPostFilter);
109
109
  }
110
110
  if (Object.keys($sort).length) {
@@ -43,8 +43,8 @@ class PagingQuery {
43
43
  this.isJsonString = isJsonString_1.isJsonString;
44
44
  this.initQuery = () => {
45
45
  const { $filter, $sort, $select, $skip, $limit, $populate, $lean } = this.params;
46
- const _a = this.options, { single, staticFilter, disablePaging, enableFilter } = _a, options = __rest(_a, ["single", "staticFilter", "disablePaging", "enableFilter"]);
47
- const filter = enableFilter ? Object.assign({}, staticFilter) : Object.assign(Object.assign({}, $filter), staticFilter);
46
+ const _a = this.options, { single, staticFilter, disablePaging, disableFilter } = _a, options = __rest(_a, ["single", "staticFilter", "disablePaging", "disableFilter"]);
47
+ const filter = disableFilter ? Object.assign({}, staticFilter) : Object.assign(Object.assign({}, $filter), staticFilter);
48
48
  this.query = single ? this.model.findOne(filter) : this.model.find(filter);
49
49
  this.query.setOptions(options);
50
50
  if (disablePaging || single) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r5v/mongoose-paginate",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "scripts": {