A simple lib that converts a object clause into a sql where clause:
ex:
var result = where2({foo: 'bar', baz: { $gt: 'bam'}});
#=> "foo = 'bar' AND baz > 'bam'"
npm install where2
var where2 = require('where2');
var result = where2({foo: { $lte: 'bar'}})
Key | Description |
---|---|
$lt | Less Than |
$lte | Less Than or Equal |
$gt | Greater Than |
$gte | Greater Than or Equal |
$ne | Not Equal To |
{"name":"foo2"}
name = "foo2"
Returns all records where name equals "foo2"
{"name":["foo2", "foo3"]}
name IN ("foo2", "foo3")
Returns all records where name equals "foo2" or "foo3"
{"name":"foo","description":"bar"}
name = "foo" AND description = "bar"
Returns all records where name equals "foo" and description equals "bar"
{"id":{"$lt":"2"}}
id < 2
Returns all records where id is less than "2"
{"id":{"$lte":"2"}}
id <= 2
Returns all records where id is less than or equal to "2"
{"id":{"$gt":"2"}}
id > 2
Returns all records where id is greater than "2"
{"id":{"$gte":"2"}}
id >= 2
Returns all records where id is greater than or equal to "2"
{"name":{"$ne":"bar"}}
name != "bar"
Returns all records where name is not equal to "bar"
- Kevin Collins kevincol54
- Tom Wilson twilson63