Module: sqlFormatter

provides formatting facilities for Microsoft Sql Server query creation
Source:
Source:

Classes

sqlFormatter
sqlFormatter

Methods

(inner) add(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) add(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) between(expr, min, max, context) → {string}

get the 'expr between min and max' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
min sqlFun | object | null | undefined
max sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) between(expr, min, max, context) → {string}

get the 'expr between min and max' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
min sqlFun | object | null | undefined
max sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) bitClear(a, b, context) → {string}

gets the 'test if Nth bit is not set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitClear('a','3') would be converted into '(a&(1<<3))=0'

(inner) bitClear(a, b, context) → {string}

gets the 'test if Nth bit is not set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitClear('a','3') would be converted into '(a&(1<<3))=0'

(inner) bitSet(a, b, context) → {string}

gets the 'test if Nth bit is set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitSet('a','3') would be converted into '(a&(1<<3))<>0'

(inner) bitSet(a, b, context) → {string}

gets the 'test if Nth bit is set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitSet('a','3') would be converted into '(a&(1<<3))<>0'

(inner) concat(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) concat(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) conditionToSql(cond, context) → {string}

Get the string filter from a sqlFunction
Parameters:
Name Type Description
cond sqlFun | string | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) conditionToSql(cond, context) → {string}

Get the string filter from a sqlFunction
Parameters:
Name Type Description
cond sqlFun | string | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) convertToInt(expr, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) convertToInt(expr, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) convertToString(expr, maxLen, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | string | null | undefined
maxLen number
context Environment
Source:
Returns:
Type
string

(inner) convertToString(expr, maxLen, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | string | null | undefined
maxLen number
context Environment
Source:
Returns:
Type
string

(inner) div(a, b, context) → {string}

gets the expression a/b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) div(a, b, context) → {string}

gets the expression a/b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) doPar(expr) → {string}

Surround expression in parenthesis
Parameters:
Name Type Description
expr string
Source:
Returns:
Type
string

(inner) doPar(expr) → {string}

Surround expression in parenthesis
Parameters:
Name Type Description
expr string
Source:
Returns:
Type
string

(inner) eq(a, b, context) → {string}

gets the 'object are equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) eq(a, b, context) → {string}

gets the 'object are equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) ge(a, b, context) → {string}

gets the 'a >= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
ge('a','b') would be converted into 'a>=b'

(inner) ge(a, b, context) → {string}

gets the 'a >= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
ge('a','b') would be converted into 'a>=b'

(inner) getObject(s, sqlType,) → {object}

Get object from a string, assuming that the strings represents a given sql type
Parameters:
Name Type Description
s string
sqlType, string one of the db specific allowed
Source:
Returns:
Type
object

(inner) getObject(s, sqlType,) → {object}

Get object from a string, assuming that the strings represents a given sql type
Parameters:
Name Type Description
s string
sqlType, string one of the db specific allowed
Source:
Returns:
Type
object

(inner) gt(a, b, context) → {string}

gets the 'a > b' representation for the db
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
gt('a','b') would be converted into 'a>b'

(inner) gt(a, b, context) → {string}

gets the 'a > b' representation for the db
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
gt('a','b') would be converted into 'a>b'

(inner) isEmptyCondition(cond) → {boolean}

Check if obj is not a real condition, giving true if it is null, undefined or empty string
Parameters:
Name Type Description
cond string | sqlFun
Source:
Returns:
Type
boolean

(inner) isEmptyCondition(cond) → {boolean}

Check if obj is not a real condition, giving true if it is null, undefined or empty string
Parameters:
Name Type Description
cond string | sqlFun
Source:
Returns:
Type
boolean

(inner) isIn(expr, list, context) → {string}

gets the 'elements belongs to list' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
list Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
isIn('el',[1,2,3,4]) would be compiled into 'el in (1,2,3,4)'

(inner) isIn(expr, list, context) → {string}

gets the 'elements belongs to list' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
list Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
isIn('el',[1,2,3,4]) would be compiled into 'el in (1,2,3,4)'

(inner) isNotNull(o, context) → {string}

get the 'is not null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isNotnull('f') would be converted as 'f is not null'

(inner) isNull(o, context) → {string}

get the 'is null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isnull('f') would be converted as 'f is null'

(inner) isNull(o, context) → {string}

get the 'is not null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isNotnull('f') would be converted as 'f is not null'

(inner) isNull(o, context) → {string}

get the 'is null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isnull('f') would be converted as 'f is null'

(inner) joinAnd(arr) → {string}

gets the result of boolean "and" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinAnd(['a','b','c']) would give 'a and b and c'

(inner) joinAnd(arr) → {string}

gets the result of boolean "and" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinAnd(['a','b','c']) would give 'a and b and c'

(inner) joinOr(arr) → {string}

gets the result of boolean "or" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinOr(['a','b','c']) would give 'a or b or c'

(inner) joinOr(arr) → {string}

gets the result of boolean "or" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinOr(['a','b','c']) would give 'a or b or c'

(inner) le(a, b, context) → {string}

gets the 'a <= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
le('a','b') would be converted into 'a<=b'

(inner) le(a, b, context) → {string}

gets the 'a <= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
le('a','b') would be converted into 'a<=b'

(inner) like(expr, mask, context) → {string}

gets the 'expression like mask' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) like(expr, mask, context) → {string}

gets the 'expression like mask' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) lt(a, b, context) → {string}

gets the 'a < b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
lt('a','b') would be converted into 'a<b'

(inner) lt(a, b, context) → {string}

gets the 'a < b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
lt('a','b') would be converted into 'a<b'

(inner) max(expr, context) → {string}

gets the aggregates of max value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) max(expr, context) → {string}

gets the aggregates of max value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) min(expr, context) → {string}

gets the aggregates of mimimum value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) min(expr, context) → {string}

gets the aggregates of mimimum value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) minus(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
-('a') would be converted into '-a'

(inner) minus(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
-('a') would be converted into '-a'

(inner) mul(arr, context) → {string}

gets the result of the multiply of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
mul(['a','b','c']) would give 'a*b*c'

(inner) mul(arr, context) → {string}

gets the result of the multiply of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
mul(['a','b','c']) would give 'a*b*c'

(inner) ne(a, b, context) → {string}

gets the 'object are not equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) ne(a, b, context) → {string}

gets the 'object are not equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) not(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
not('a') would be converted into 'not(a)'

(inner) not(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
not('a') would be converted into 'not(a)'

(inner) quote(v, noSurroundQuotesopt) → {string}

Gives the sql string representation of an object
Parameters:
Name Type Attributes Description
v object literal constant
noSurroundQuotes <optional>
if true strings are not surrounded with quotes
Source:
Returns:
Type
string

(inner) quote(v, noSurroundQuotesopt) → {string}

Gives the sql string representation of an object
Parameters:
Name Type Attributes Description
v object literal constant
noSurroundQuotes <optional>
if true strings are not surrounded with quotes
Source:
Returns:
Type
string

(inner) sub(a, b, context) → {string}

gets the expression a-b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) sub(a, b, context) → {string}

gets the expression a-b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) substring(expr, start, len, context) → {string}

gets a substring from the expression
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
start number
len number
context Environment
Source:
Returns:
Type
string

(inner) substring(expr, start, len, context) → {string}

gets a substring from the expression
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
start number
len number
context Environment
Source:
Returns:
Type
string

(inner) sum(expr, context) → {string}

gets the expression sum(expr)
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) sum(exprList, context) → {string}

gets the expression distinct expr1, expr2,..
Parameters:
Name Type Description
exprList Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string

(inner) sum(expr, context) → {string}

gets the expression sum(expr)
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) sum(exprList, context) → {string}

gets the expression distinct expr1, expr2,..
Parameters:
Name Type Description
exprList Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string

(inner) testMask(expr, mask, val, context) → {string}

get the '(expr (bitwise and) testMask) equal to val ' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
val sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
testMask('a',5,1) would give '(a &  5) = 1'

(inner) testMask(expr, mask, val, context) → {string}

get the '(expr (bitwise and) testMask) equal to val ' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
val sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
testMask('a',5,1) would give '(a &  5) = 1'

(inner) toSql(v, context) → {string}

Converts a function into a sql expression. The result is meant to be used as conditional expression in sql WHERE clauses. Usually you will not use this function, but instead you will use the toSql method of dataquery objects. This can be used to manage slightly more generic objects like null values, undefined, arrays. Arrays are converted into lists.
Parameters:
Name Type Description
v sqlFun | Array | object | null | undefined function to be converted
context Environment context into which the expression has to be evaluated
Source:
Returns:
Type
string
Example
eq('a',1) is converted into 'a=1'
 eq('a','1') is converted into 'a=\'1\'' i.e. strings are quoted when evaluated
 [1,2,3] is converted into (1,2,3)

(inner) toSql(v, context) → {string}

Converts a function into a sql expression. The result is meant to be used as conditional expression in sql WHERE clauses. Usually you will not use this function, but instead you will use the toSql method of dataquery objects. This can be used to manage slightly more generic objects like null values, undefined, arrays. Arrays are converted into lists.
Parameters:
Name Type Description
v sqlFun | Array | object | null | undefined function to be converted
context Environment context into which the expression has to be evaluated
Source:
Returns:
Type
string
Example
eq('a',1) is converted into 'a=1'
 eq('a','1') is converted into 'a=\'1\'' i.e. strings are quoted when evaluated
 [1,2,3] is converted into (1,2,3)
provides formatting facilities for Microsoft Sql Server query creation
Source:
Source:

Classes

sqlFormatter
sqlFormatter

Methods

(inner) add(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) add(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) between(expr, min, max, context) → {string}

get the 'expr between min and max' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
min sqlFun | object | null | undefined
max sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) between(expr, min, max, context) → {string}

get the 'expr between min and max' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
min sqlFun | object | null | undefined
max sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) bitClear(a, b, context) → {string}

gets the 'test if Nth bit is not set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitClear('a','3') would be converted into '(a&(1<<3))=0'

(inner) bitClear(a, b, context) → {string}

gets the 'test if Nth bit is not set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitClear('a','3') would be converted into '(a&(1<<3))=0'

(inner) bitSet(a, b, context) → {string}

gets the 'test if Nth bit is set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitSet('a','3') would be converted into '(a&(1<<3))<>0'

(inner) bitSet(a, b, context) → {string}

gets the 'test if Nth bit is set' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
bitSet('a','3') would be converted into '(a&(1<<3))<>0'

(inner) concat(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) concat(arr, context) → {string}

gets the result of the sum of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
add(['a','b','c']) would give 'a+b+c'

(inner) conditionToSql(cond, context) → {string}

Get the string filter from a sqlFunction
Parameters:
Name Type Description
cond sqlFun | string | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) conditionToSql(cond, context) → {string}

Get the string filter from a sqlFunction
Parameters:
Name Type Description
cond sqlFun | string | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) convertToInt(expr, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) convertToInt(expr, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) convertToString(expr, maxLen, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | string | null | undefined
maxLen number
context Environment
Source:
Returns:
Type
string

(inner) convertToString(expr, maxLen, context) → {string}

Convert an expression into integer
Parameters:
Name Type Description
expr sqlFun | string | null | undefined
maxLen number
context Environment
Source:
Returns:
Type
string

(inner) div(a, b, context) → {string}

gets the expression a/b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) div(a, b, context) → {string}

gets the expression a/b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) doPar(expr) → {string}

Surround expression in parenthesis
Parameters:
Name Type Description
expr string
Source:
Returns:
Type
string

(inner) doPar(expr) → {string}

Surround expression in parenthesis
Parameters:
Name Type Description
expr string
Source:
Returns:
Type
string

(inner) eq(a, b, context) → {string}

gets the 'object are equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) eq(a, b, context) → {string}

gets the 'object are equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) ge(a, b, context) → {string}

gets the 'a >= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
ge('a','b') would be converted into 'a>=b'

(inner) ge(a, b, context) → {string}

gets the 'a >= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
ge('a','b') would be converted into 'a>=b'

(inner) getObject(s, sqlType,) → {object}

Get object from a string, assuming that the strings represents a given sql type
Parameters:
Name Type Description
s string
sqlType, string one of the db specific allowed
Source:
Returns:
Type
object

(inner) getObject(s, sqlType,) → {object}

Get object from a string, assuming that the strings represents a given sql type
Parameters:
Name Type Description
s string
sqlType, string one of the db specific allowed
Source:
Returns:
Type
object

(inner) gt(a, b, context) → {string}

gets the 'a > b' representation for the db
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
gt('a','b') would be converted into 'a>b'

(inner) gt(a, b, context) → {string}

gets the 'a > b' representation for the db
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
gt('a','b') would be converted into 'a>b'

(inner) isEmptyCondition(cond) → {boolean}

Check if obj is not a real condition, giving true if it is null, undefined or empty string
Parameters:
Name Type Description
cond string | sqlFun
Source:
Returns:
Type
boolean

(inner) isEmptyCondition(cond) → {boolean}

Check if obj is not a real condition, giving true if it is null, undefined or empty string
Parameters:
Name Type Description
cond string | sqlFun
Source:
Returns:
Type
boolean

(inner) isIn(expr, list, context) → {string}

gets the 'elements belongs to list' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
list Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
isIn('el',[1,2,3,4]) would be compiled into 'el in (1,2,3,4)'

(inner) isIn(expr, list, context) → {string}

gets the 'elements belongs to list' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
list Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
isIn('el',[1,2,3,4]) would be compiled into 'el in (1,2,3,4)'

(inner) isNotNull(o, context) → {string}

get the 'is not null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isNotnull('f') would be converted as 'f is not null'

(inner) isNull(o, context) → {string}

get the 'is null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isnull('f') would be converted as 'f is null'

(inner) isNull(o, context) → {string}

get the 'is not null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isNotnull('f') would be converted as 'f is not null'

(inner) isNull(o, context) → {string}

get the 'is null' condition over object o
Parameters:
Name Type Description
o sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
isnull('f') would be converted as 'f is null'

(inner) joinAnd(arr) → {string}

gets the result of boolean "and" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinAnd(['a','b','c']) would give 'a and b and c'

(inner) joinAnd(arr) → {string}

gets the result of boolean "and" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinAnd(['a','b','c']) would give 'a and b and c'

(inner) joinOr(arr) → {string}

gets the result of boolean "or" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinOr(['a','b','c']) would give 'a or b or c'

(inner) joinOr(arr) → {string}

gets the result of boolean "or" between an array of condition
Parameters:
Name Type Description
arr Array.<string>
Source:
Returns:
Type
string
Example
joinOr(['a','b','c']) would give 'a or b or c'

(inner) le(a, b, context) → {string}

gets the 'a <= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
le('a','b') would be converted into 'a<=b'

(inner) le(a, b, context) → {string}

gets the 'a <= b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
le('a','b') would be converted into 'a<=b'

(inner) like(expr, mask, context) → {string}

gets the 'expression like mask' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) like(expr, mask, context) → {string}

gets the 'expression like mask' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) lt(a, b, context) → {string}

gets the 'a < b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
lt('a','b') would be converted into 'a<b'

(inner) lt(a, b, context) → {string}

gets the 'a < b' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
lt('a','b') would be converted into 'a<b'

(inner) max(expr, context) → {string}

gets the aggregates of max value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) max(expr, context) → {string}

gets the aggregates of max value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) min(expr, context) → {string}

gets the aggregates of mimimum value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) min(expr, context) → {string}

gets the aggregates of mimimum value
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) minus(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
-('a') would be converted into '-a'

(inner) minus(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
-('a') would be converted into '-a'

(inner) mul(arr, context) → {string}

gets the result of the multiply of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
mul(['a','b','c']) would give 'a*b*c'

(inner) mul(arr, context) → {string}

gets the result of the multiply of an array of expression
Parameters:
Name Type Description
arr Array.<(sqlFun|Array|object|null|undefined)>
context Environment
Source:
Returns:
Type
string
Example
mul(['a','b','c']) would give 'a*b*c'

(inner) ne(a, b, context) → {string}

gets the 'object are not equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) ne(a, b, context) → {string}

gets the 'object are not equal' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
b sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) not(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
not('a') would be converted into 'not(a)'

(inner) not(a, context) → {string}

gets the 'not expression' representation for the db
Parameters:
Name Type Description
a sqlFun | Array | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
not('a') would be converted into 'not(a)'

(inner) quote(v, noSurroundQuotesopt) → {string}

Gives the sql string representation of an object
Parameters:
Name Type Attributes Description
v object literal constant
noSurroundQuotes <optional>
if true strings are not surrounded with quotes
Source:
Returns:
Type
string

(inner) quote(v, noSurroundQuotesopt) → {string}

Gives the sql string representation of an object
Parameters:
Name Type Attributes Description
v object literal constant
noSurroundQuotes <optional>
if true strings are not surrounded with quotes
Source:
Returns:
Type
string

(inner) sub(a, b, context) → {string}

gets the expression a-b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) sub(a, b, context) → {string}

gets the expression a-b
Parameters:
Name Type Description
a sqlFun | object | null | undefined
b sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) substring(expr, start, len, context) → {string}

gets a substring from the expression
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
start number
len number
context Environment
Source:
Returns:
Type
string

(inner) substring(expr, start, len, context) → {string}

gets a substring from the expression
Parameters:
Name Type Description
expr sqlFun | Array | object | null | undefined
start number
len number
context Environment
Source:
Returns:
Type
string

(inner) sum(expr, context) → {string}

gets the expression sum(expr)
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) sum(exprList, context) → {string}

gets the expression distinct expr1, expr2,..
Parameters:
Name Type Description
exprList Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string

(inner) sum(expr, context) → {string}

gets the expression sum(expr)
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string

(inner) sum(exprList, context) → {string}

gets the expression distinct expr1, expr2,..
Parameters:
Name Type Description
exprList Array.<(sqlFun|object|null|undefined)>
context Environment
Source:
Returns:
Type
string

(inner) testMask(expr, mask, val, context) → {string}

get the '(expr (bitwise and) testMask) equal to val ' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
val sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
testMask('a',5,1) would give '(a &  5) = 1'

(inner) testMask(expr, mask, val, context) → {string}

get the '(expr (bitwise and) testMask) equal to val ' sql condition
Parameters:
Name Type Description
expr sqlFun | object | null | undefined
mask sqlFun | object | null | undefined
val sqlFun | object | null | undefined
context Environment
Source:
Returns:
Type
string
Example
testMask('a',5,1) would give '(a &  5) = 1'

(inner) toSql(v, context) → {string}

Converts a function into a sql expression. The result is meant to be used as conditional expression in sql WHERE clauses. Usually you will not use this function, but instead you will use the toSql method of dataquery objects. This can be used to manage slightly more generic objects like null values, undefined, arrays. Arrays are converted into lists.
Parameters:
Name Type Description
v sqlFun | Array | object | null | undefined function to be converted
context Environment context into which the expression has to be evaluated
Source:
Returns:
Type
string
Example
eq('a',1) is converted into 'a=1'
 eq('a','1') is converted into 'a=\'1\'' i.e. strings are quoted when evaluated
 [1,2,3] is converted into (1,2,3)

(inner) toSql(v, context) → {string}

Converts a function into a sql expression. The result is meant to be used as conditional expression in sql WHERE clauses. Usually you will not use this function, but instead you will use the toSql method of dataquery objects. This can be used to manage slightly more generic objects like null values, undefined, arrays. Arrays are converted into lists.
Parameters:
Name Type Description
v sqlFun | Array | object | null | undefined function to be converted
context Environment context into which the expression has to be evaluated
Source:
Returns:
Type
string
Example
eq('a',1) is converted into 'a=1'
 eq('a','1') is converted into 'a=\'1\'' i.e. strings are quoted when evaluated
 [1,2,3] is converted into (1,2,3)