Skip to content
Angel Alvarado edited this page Nov 21, 2015 · 6 revisions

Here is a list of available API's ( work in progress )

###.transform() Permanently transforms all objects with either adding or altering a property, then calculating that property via result of a callback. This cannot be undone unless you create a new JSQL object, even if you use .select();

.transform(function(obj){
  obj.full_name obj.first + obj.last];
});

###.select() Every query must start with .select() this is used to reset the internal matched values

.select()
.select("first", "last")

###.where() .where() is case sensitive

.where("first", "Angel")
.where({"first": "Angel", "city": "Atlanta"}) // AND
.where({"first": "Angel", "city": "Atlanta"}, {"city": "New York"}, , {"city": "Jacksonville"}) // OR

###.in | .notIn .in/.notIn case sensitive

.in('age', [18, 21, 65])
.notIn('city', ["New York", "Orlando"])

###.lt() | .ltg() | .gt() | .gte()

.lt("age", 18)
.lte("age", 18)
.gt("age", 18)
.gte("age", 18)

###.between() .between is inclusive except when true is passed in as an optional argument

.between("age", 18, 21) // inclusive
.between("age", 18, 21, true) // exclusive

###.regEx() .regEx uses regular expression as a second argument, case sensitive

.regEx("first", /^m|M.*s$/)

###.like() | .startsWith() | .endsWith() The following are all case insensitive

.like("city", "grove")
.startsWith("city", "st")
.endsWith("email", ".com")

.sortBy()

Various ways to sort

.sortBy("age")
.sortBy("age", "asc")
.sortBy("age", "desc")
.sortBy({"name": "asc", "age": "desc"})
.sortAsc("name")
.sortDesc("age")

###.limit() Works like SQL limit(limit, offset)

.limit(10)
.limit(10, 20)

###.get() Returns elements that match the query, can be used multiple times throughout chaining

.get()
Clone this wiki locally