Closed emilkje closed 8 years ago
I see this as adding more code to db.js to solve a problem that is already quite easy to solve in your own code - https://github.com/aaronpowell/db.js/blob/master/tests/specs/query.js#L209-L232 and if you combine it with an ES6 transpiler it gets even simpler:
db.query('people').filter(r => r.firstName == 'Aaron' && r.lastName == 'Powell')
I think its a really common use case to filter the results on more than one attribute, and I found the function
api a little verbose for my taste. I was however not aware that the ES6 compiler made the api more friendly in that regard. I just found myself writing a helper resource.getBy({prop: 'value'})
and thought it would be a nice addition to your library thats all.
My personal opinion is that this does make things more elegant, even with the ES6 syntax.
Closing - very out of date.
I found it confusing why the filter would not accept object as filter method. This is now fixed. It generates a function which returns true if record has all and match all properties on the filter object.
Updated README and added tests.