I really like mongodb's json dsl for querying the database. I was wondering if there is any stand alone library for node.js/browser that can convert that kind of json expressions into, maybe, js functions that you can apply on certain context object.
Here's what I mean. Say you have the following expression:
{
"context.user.age": { "$gte": 30, "$lte": 40 },
"context.user.hobby": { "$in": ["swimming", "running"] }
}
This could be translated into a js function:
var f = function (context) {
// @return {Boolean}
return (context.user.age >= 30) &&
(context.user.age <= 40) &&
(['swimming', 'running'].indexOf(context.user.hobby) >= 0)
}
I need this because I'm building my own DSL. So, do you know anything with this kind of functionality?