make _like operator case insensitive

This commit is contained in:
Typicode
2016-05-12 21:46:17 +02:00
parent c63c1d9bd3
commit dfea2b3400
4 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,9 @@
# Change Log
## [0.8.13][2016-05-12]
* Make `_like` operator case insensitive
## [0.8.12][2016-05-08]
* Minor bug fix
@ -11,8 +15,6 @@
## [0.8.10][2016-04-18]
### Added
* CLI option `-ng/--no-gzip` to disable `gzip` compression
## [0.8.9][2016-03-17]

View File

@ -118,7 +118,7 @@ Add `_ne` to exclude a value
GET /posts?id_ne=1
```
Add `_like` to filter using RegExp
Add `_like` to filter (RegExp supported)
```
GET /posts?title_like=server

View File

@ -125,7 +125,7 @@ module.exports = function (db, name) {
} else if (isDifferent) {
return value !== elementValue
} else if (isLike) {
return new RegExp(value).test(elementValue)
return new RegExp(value, 'i').test(elementValue)
} else {
return _.matchesProperty(key, value)(element)
}

View File

@ -259,9 +259,9 @@ describe('Server', function () {
})
describe('GET /:resource?attr_like=', function () {
it('should respond with an array that matches the like operator', function (done) {
it('should respond with an array that matches the like operator (case insensitive)', function (done) {
request(server)
.get('/tags?body_like=hoto')
.get('/tags?body_like=photo')
.expect('Content-Type', /json/)
.expect([
db.tags[1],