What Javascript library can evaluate MongoDB-like query predicates against an object?
问题 Is there a javascript library that will allow me to express object predicates in a DSL similar to MongoDB's query language? For the sake of clarity in a large program, I'd like to be able to say: var obj = { a: 1, b: 'abcdefg' }, qry = { a: { $gt: 0 }, b: /^abc/ }; if(query(qry).matches(obj)) { // do something appropriate since } instead of: var obj = { a: 1, b: 'abcdefg' }; if(obj.a>0 && qry.b.test(obj.b)) { // do something appropriate } I'm using Node.js, so anything on NPM would be great.