@r5v/mongoose-paginate 1.0.11 → 1.0.13
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
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
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,14 @@ $ 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.13
|
|
140
|
+
- Fix issue where disablePaging was not working on aggregation query
|
|
141
|
+
|
|
142
|
+
### 1.0.12
|
|
143
|
+
- Fix issue with AggregationPagingQuery where static post filter would not be applied if $postFilter param was not supplied
|
|
144
|
+
- updated typings on AggregationPagingQuery to include enablePostFilter, enableFilter, and enablePreSort
|
|
145
|
+
- flipped PagingQuery back to `disableFilter` instead of `enableFilter` option \# this was set incorrectly in 1.0.11 but still defaults to false
|
|
146
|
+
|
|
137
147
|
### 1.0.11
|
|
138
148
|
Fix Issue with Typescript build
|
|
139
149
|
|
|
@@ -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.
|
|
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) {
|
|
@@ -150,11 +150,11 @@ class AggregationPagingQuery {
|
|
|
150
150
|
};
|
|
151
151
|
this.exec = () => __awaiter(this, void 0, void 0, function* () {
|
|
152
152
|
const { $skip, $limit, $paging, $filter } = this.params;
|
|
153
|
-
const {
|
|
153
|
+
const { disablePaging } = this.options;
|
|
154
154
|
if (!this.query) {
|
|
155
155
|
throw new Error("No Query Present in AggregationQuery");
|
|
156
156
|
}
|
|
157
|
-
if (!$paging) {
|
|
157
|
+
if (!$paging || disablePaging) {
|
|
158
158
|
this.query.skip($skip);
|
|
159
159
|
this.query.limit($limit);
|
|
160
160
|
return yield this.query.exec();
|
package/dist/pagingQuery.js
CHANGED
|
@@ -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,
|
|
47
|
-
const filter =
|
|
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) {
|
|
@@ -48,7 +48,9 @@ export interface PagingQueryOptions extends StandardQueryOptions {
|
|
|
48
48
|
};
|
|
49
49
|
single?: boolean;
|
|
50
50
|
}
|
|
51
|
-
export interface AggregateQueryOptions extends
|
|
51
|
+
export interface AggregateQueryOptions extends Omit<AggregateOptions, 'comment'> {
|
|
52
|
+
enableFilter?: boolean;
|
|
53
|
+
disablePaging?: boolean;
|
|
52
54
|
disablePostFilter?: boolean;
|
|
53
55
|
disablePreSort?: boolean;
|
|
54
56
|
staticPostFilter?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,EAAE,EAAC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,IAAI,CAAC;AAE5B,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;I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