执行复杂JavaScript对象搜索的查询语言:queryl

jopen 9年前

Queryl能够实现构建复杂的查询来匹配JavaScript对象。它可用于:

  • 搜索对象集合 (甚至是heterogeneus).
  • 验证对象。
  • Assert properties of an object for testing purposes.

Check the FAQ for answers to common questions!

Installation

Installquerylby running:

$ npm install --save queryl

Documentation

queryl.match(query, object) ⇒Boolean

Kind: static method ofqueryl
Summary: Query an object
Returns:Boolean- whether it matches or not
Access: public

Param Type Description
query Object query
object Object object

Example

queryl.match({    $or: {      $equal: {        foo: 'bar'      },      $and: {        $not: {          $match: {            foo: /^baz/          }        },        $gt: {          bar: 3        }      }    }  }, {    foo: 'hello world',    bar: 5  });  > true

项目主页:http://www.open-open.com/lib/view/home/1443191593091