Giter Club home page Giter Club logo

where2's Introduction

Where2

build status

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'"

Install

npm install where2

Usage

var where2 = require('where2');

var result = where2({foo: { $lte: 'bar'}})

Where Attributes

Key Description
$lt Less Than
$lte Less Than or Equal
$gt Greater Than
$gte Greater Than or Equal
$ne Not Equal To

JSON Examples

Where

where single equals:

{"name":"foo2"}

name = "foo2"

Returns all records where name equals "foo2"

where in collection:

{"name":["foo2", "foo3"]}

name IN ("foo2", "foo3")

Returns all records where name equals "foo2" or "foo3"

where multiple equals:

{"name":"foo","description":"bar"}

name = "foo" AND description = "bar"

Returns all records where name equals "foo" and description equals "bar"

where less than:

{"id":{"$lt":"2"}}

id < 2

Returns all records where id is less than "2"

where less than or equal to:

{"id":{"$lte":"2"}}

id <= 2

Returns all records where id is less than or equal to "2"

where greater than:

{"id":{"$gt":"2"}}

id > 2

Returns all records where id is greater than "2"

where greater than or equal to:

{"id":{"$gte":"2"}}

id >= 2

Returns all records where id is greater than or equal to "2"

where not equal to:

{"name":{"$ne":"bar"}}

name != "bar"

Returns all records where name is not equal to "bar"

Collaborators

where2's People

Contributors

jaymcaliley avatar kevincol54 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.