express-query-params
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -49,2 +49,4 @@ 'use strict'; | ||
parsed[p] = query[p] === 'true' ? true : false; | ||
} else if (query[p][0] === '^') { | ||
parsed[p] = new RegExp(query[p] + '$', 'i'); | ||
} else { | ||
@@ -77,2 +79,4 @@ parsed[p] = query[p]; | ||
parsed += p + ' ' + operator + ' ' + typeCast(query[p].split(operator).join('')); | ||
} else if (query[p][0] === '^') { | ||
parsed += p + ' ILIKE `' + query[p].slice(1) + '`'; | ||
} else { | ||
@@ -79,0 +83,0 @@ parsed += p + ' = `' + query[p] + '`'; |
{ | ||
"name": "express-query-params", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Express.js middleware implementing the API Query Spec, converting the params to SQL or a Mongo query", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha", | ||
"package:update": "npm outdated --depth=0 | grep -v Package | awk '{print $1}' | xargs -I% npm install %@latest --save" | ||
}, | ||
@@ -9,0 +10,0 @@ "repository": { |
@@ -24,2 +24,4 @@ # Mongo Express Query Params | ||
Inside any downstream middleware, this plugin will create a `parsedQuery` object on the `request`. See the [test](https://github.com/mtimofiiv/express-query-params/blob/master/test/test.js) to see how it works. | ||
## Advanced Usage | ||
@@ -26,0 +28,0 @@ |
@@ -21,3 +21,4 @@ 'use strict'; | ||
banned: 'false', | ||
activated: 'true' | ||
activated: 'true', | ||
firstName: '^Steve' | ||
} | ||
@@ -73,2 +74,6 @@ }; | ||
}); | ||
it('parses a case-insensitive query properly', function() { | ||
expect(request.parsedQuery).to.contain('firstName ILIKE `Steve`'); | ||
}); | ||
}); | ||
@@ -129,2 +134,7 @@ | ||
it('parses a case-insensitive query properly', function() { | ||
expect(request.parsedQuery.firstName).to.be.instanceof(RegExp) | ||
expect(request.parsedQuery.firstName.toString()).to.equal((/^Steve$/i).toString()); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10205
7
194
63