nestjs-paginate
Advanced tools
Comparing version 2.3.3 to 2.4.0
@@ -47,2 +47,3 @@ import { Repository, FindConditions, SelectQueryBuilder, FindOperator } from 'typeorm'; | ||
LTE = "$lte", | ||
BTW = "$btw", | ||
NOT = "$not" | ||
@@ -49,0 +50,0 @@ } |
@@ -20,2 +20,3 @@ "use strict"; | ||
FilterOperator["LTE"] = "$lte"; | ||
FilterOperator["BTW"] = "$btw"; | ||
FilterOperator["NOT"] = "$not"; | ||
@@ -43,2 +44,4 @@ })(FilterOperator = exports.FilterOperator || (exports.FilterOperator = {})); | ||
return typeorm_1.LessThanOrEqual; | ||
case FilterOperator.BTW: | ||
return typeorm_1.Between; | ||
case FilterOperator.NOT: | ||
@@ -101,3 +104,4 @@ return typeorm_1.Not; | ||
const args = op1 === FilterOperator.IN ? value.split(',') : value; | ||
filter[column] = getOperatorFn(op1)(args); | ||
filter[column] = | ||
op1 === FilterOperator.BTW ? getOperatorFn(op1)(args[0], args[1]) : getOperatorFn(op1)(args); | ||
} | ||
@@ -104,0 +108,0 @@ if (isOperator(op2)) { |
@@ -313,2 +313,19 @@ "use strict"; | ||
}); | ||
it('should return result based on between range filter', async () => { | ||
const config = { | ||
sortableColumns: ['id'], | ||
filterableColumns: { | ||
age: [paginate_1.FilterOperator.BTW], | ||
}, | ||
}; | ||
const query = { | ||
path: '', | ||
filter: { | ||
age: '$btw:4,6', | ||
}, | ||
}; | ||
const result = await (0, paginate_1.paginate)(query, repo, config); | ||
expect(result.data).toStrictEqual([cats[0], cats[2]]); | ||
expect(result.links.current).toBe('?page=1&limit=20&sortBy=id:ASC&filter.age=$btw:4,6'); | ||
}); | ||
it('should return result based on is null query', async () => { | ||
@@ -404,2 +421,3 @@ const config = { | ||
{ operator: '$lte', result: true }, | ||
{ operator: '$btw', result: true }, | ||
{ operator: '$not', result: true }, | ||
@@ -418,2 +436,3 @@ { operator: '$fake', result: false }, | ||
{ operator: '$lte', name: 'LessThanOrEqual' }, | ||
{ operator: '$btw', name: 'Between' }, | ||
{ operator: '$not', name: 'Not' }, | ||
@@ -420,0 +439,0 @@ ])('should get operator function $name for "$operator"', ({ operator, name }) => { |
{ | ||
"name": "nestjs-paginate", | ||
"version": "2.3.3", | ||
"version": "2.4.0", | ||
"author": "Philipp Petzold <ppetzold@protonmail.com>", | ||
@@ -33,7 +33,7 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@nestjs/common": "^8.2.3", | ||
"@nestjs/common": "^8.2.6", | ||
"@types/express": "^4.17.13", | ||
"@types/jest": "^27.0.2", | ||
"@types/lodash": "^4.14.178", | ||
"@types/node": "^16.11.12", | ||
"@types/node": "^16.11.21", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
@@ -44,12 +44,12 @@ "@typescript-eslint/parser": "^4.33.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"fastify": "^3.24.1", | ||
"fastify": "^3.27.0", | ||
"jest": "^27.2.5", | ||
"prettier": "^2.5.1", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.4.0", | ||
"rxjs": "^7.5.2", | ||
"sqlite3": "^5.0.2", | ||
"ts-jest": "^27.1.1", | ||
"ts-jest": "^27.1.3", | ||
"ts-node": "^10.4.0", | ||
"typeorm": "^0.2.41", | ||
"typescript": "^4.5.3" | ||
"typescript": "^4.5.5" | ||
}, | ||
@@ -60,5 +60,5 @@ "dependencies": { | ||
"peerDependencies": { | ||
"@nestjs/common": "^8.2.3", | ||
"express": "^4.17.1", | ||
"fastify": "^3.24.1", | ||
"@nestjs/common": "^8.2.6", | ||
"express": "^4.17.2", | ||
"fastify": "^3.27.0", | ||
"typeorm": "^0.2.41" | ||
@@ -65,0 +65,0 @@ }, |
@@ -16,3 +16,3 @@ # Nest.js Paginate | ||
- Search across columns | ||
- Filter using operators (`$eq`, `$not`, `$null`, `$in`, `$gt`, `$gte`, `$lt`, `$lte`) | ||
- Filter using operators (`$eq`, `$not`, `$null`, `$in`, `$gt`, `$gte`, `$lt`, `$lte`, `$btw`) | ||
@@ -19,0 +19,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
215139
21448
950
117
3
4
2
16