jsDataQuery Class
Compare function provider to help building conditions that can be applyed both to collections, using the returned function as a filter, or to a database, using the toSql() method
Item Index
Methods
- add
- and
- as
- autofield
- between
- bitClear
- bitSet
- bitwiseAnd
- bitwiseNot
- bitwiseOr
- bitwiseXor
- calc
- concat
- constant
- context
- convertToInt
- convertToString
- distinctVal
- distinctVal
- div
- eq
- field
- ge
- gt
- isIn
- isNotIn
- isNotNull
- isNull
- isNullOrEq
- isNullOrGe
- isNullOrGt
- isNullOrLe
- isNullOrLt
- isNullOrUndefined
- le
- like
- list
- lt
- max
- mcmp
- mcmpEq
- mcmpLike
- min
- minus
- modulus
- mul
- ne
- not
- or
- sub
- substring
- sum
- testMask
- toSqlFun
Methods
add
-
values
returns a functions that evaluates the sum of a list or array of values given when it is CREATED
Parameters:
-
values
SqlFun | Object[]
Returns:
and
-
arr
checks if all supplied expression evaluate to truthy values
Parameters:
-
arr
SqlFun | Object[]array or list of expression
Returns:
as
-
fieldName
Establish the output name for an expression
Parameters:
-
fieldName
String
Returns:
between
-
expr1
-
min
-
max
Check if expr1 evaluates between min and max
Parameters:
Returns:
bitClear
-
expression
-
nbit
Check if the nth bit of expression is not set
Parameters:
Returns:
bitSet
-
expression
-
nbit
Check if the nth bit of expression is set
Parameters:
Returns:
bitwiseAnd
-
arr
Parameters:
-
arr
SqlFun | Object[]array or list of expression
Returns:
bitwiseNot
-
}
Parameters:
Returns:
bitwiseOr
-
arr
Parameters:
-
arr
SqlFun | Object[]array or list of expression
Returns:
bitwiseXor
-
arr
Parameters:
-
arr
SqlFun | Object[]array or list of expression
Returns:
calc
-
expr
-
r
-
context
Evaluates an expression in a given context
concat
-
values
returns a functions that evaluates the concatenation of a list or array of strings given when it is CREATED
Parameters:
-
values
SqlFun | Object[]
Returns:
constant
-
value
Defines a constant function. The toSql method invokes the formatter.quote function
Parameters:
-
value
Objectis a literal
Returns:
f such that f()= k, f.toSql()= formatter.quote(k)
context
-
environmentVariable
Transforms a generic function into a sqlFun, returning a similar function with some additional methods
Parameters:
-
environmentVariable
StringEnvironment variable name
Returns:
Example:
if environment = {a:1, b:2} and environmentFunction = function (env){return env.a} context(environmentFunction) applied to environment will return 1
convertToInt
-
expr1
Converts a generic expression into an integer
Returns:
convertToString
-
expr1
-
maxLen
Converts a generic expression into a string
Returns:
distinctVal
-
arr
-
fieldname
Finds distinct values of a field
Returns:
distinctVal
-
exprList
Finds distinct values of a list of fields
Parameters:
-
exprList
(sqlFun | Object)
Returns:
div
-
expr1
-
expr2
returns a functions that does a division
Returns:
eq
-
expr1
-
expr2
checks if expr1 evaluates equal to expr2
Parameters:
Returns:
field
-
fieldName
-
[tableName]
Gets a field from an object. This is a very important function to distinguish between generic strings and field names.
Returns:
f such that f(r) = r[fieldName] f.toSql() = 'fieldName' or 'tableName.fieldName' where tableName is specified
ge
-
expr1
-
expr2
checks if expr1 evaluates greater than or equal to expr2
Parameters:
Returns:
gt
-
expr1
-
expr2
checks if expr1 evaluates greater than expr2
Parameters:
Returns:
isIn
-
expr1
-
list
checks if expr1 is in the array list
Parameters:
Returns:
isNotIn
-
expr1
-
list
checks if expr1 is not in the array list
Parameters:
Returns:
isNotNull
-
expr1
Check if an expression does not evaluate to null
Returns:
f where f(expr) = true if expr does not evaluate to null f.toSql() = something like '(EXPR is not null)' where EXPR is the sql representation of the given expr
isNull
-
expr1
Check if an expression evaluates to null
Returns:
f where f(expr) = true if expr evaluates to null f.toSql() = something like '(EXPR is null)' where EXPR is the sql representation of the given expr
isNullOrEq
-
expr1
-
expr2
checks if expr1 is null or equal to expr2
Parameters:
Returns:
isNullOrGe
-
expr1
-
expr2
checks if expr1 is null or greater than or equal to expr2
Parameters:
Returns:
isNullOrGt
-
expr1
-
expr2
checks if expr1 is null or greater than expr2
Parameters:
Returns:
isNullOrLe
-
expr1
-
expr2
checks if expr1 is null or less than or equal to expr2
Parameters:
Returns:
isNullOrLt
-
expr1
-
expr2
checks if expr1 is null or less than expr2
Parameters:
Returns:
isNullOrUndefined
-
o
Check if an object is the null or undefined constant
Parameters:
-
o
SqlFun | Undefined | Null | Object
Returns:
true if o is null or undefined
le
-
expr1
-
expr2
checks if expr1 evaluates less than or equal to from expr2
Parameters:
Returns:
like
-
expr1
-
mask
Checks if expr1 is (sql-like) mask, where mask can contain * and _ characters
Parameters:
Returns:
Example:
like('a','s%') compiles into (a like 's%') like(const('a'),'s%') compiles into ('a' like 's%')
list
-
values
returns an array list from the parameters if all the parameters are legal. Oterwise it returns undefined or null.
Parameters:
-
values
SqlFun | Object[]
Returns:
lt
-
expr1
-
expr2
checks if expr1 evaluates less than from expr2
Parameters:
Returns:
max
-
expr1
Evaluates the maximum value of an expression in a table. If any undefined is found, return undefined. Null are skipped. If all is null return null
Returns:
mcmp
-
keys
-
values
-
[alias]
Compares a set of keys of an object with an array of values or with fields of another object values can be an array or an object
Returns:
f(r) = true if : case values is an array: r[keys[i]] = values[i] for each i=0..keys.length-1 case values is an object: r[keys[i]] = values[keys[i]] for each i=0..keys.length-1
mcmpEq
-
example
-
[alias]
Compares a set of keys of an object with an array of values or with fields of another object
Returns:
f(r) = true if for each non empty field of r: case field is null : field is null otherwise: r[field] = example[field]
mcmpLike
-
example
-
[alias]
Compares a set of keys of an object with an array of values or with fields of another object
Parameters:
Returns:
f(r) = true if for each non empty field of r: case field is a string containing a %: field LIKE example[field] otherwise: field = example[field]
min
-
expr1
Evaluates the minimum value of an expression in a table. If any undefined is found, return undefined. Null are skipped. If all is null return null
Returns:
minus
-
expr1
Returns:
f where f(r) = - r. r should evaluate into a number
modulus
-
expr1
-
expr2
returns a functions that does the modulus
Returns:
mul
-
values
returns a functions that evaluates the multiply of a list or array of values If some operand is 0, returns the always 0 function
Parameters:
-
values
SqlFun | Object[]
Returns:
ne
-
expr1
-
expr2
checks if expr1 evaluates different from expr2
Parameters:
Returns:
not
-
expr1
Returns:
f where f(r) = not r. r should evaluate into a boolean
or
-
arr
checks if at least one of supplied expression evaluates to a truthy value
Parameters:
-
arr
SqlFun | Object[]array or list of expression
Returns:
sub
-
expr1
-
expr2
returns a functions that does a subtraction
Returns:
substring
-
expr1
-
start
-
len
Returns:
sum
-
expr1
Evaluates the sum of an array of element given at run time
Returns:
testMask
-
expr1
-
mask
-
val
check if expr1 & mask === val & mask