WhereBuilder Object
The WhereBuilder Object is a helper object to build where expressions from a script. Where expressions are used to filter a request by applying extra conditions. These expressions are generally stored as an XML-formatted string, however, the scripting implementation can unwrap these in a tree. The WhereBuilder object can be used to create new instances of these objects. WhereBuilder can be accessed from any script, because it is a globally accessible type, just use it like: WhereBuilder.createNull()
to create a new null where object.
The code snippet below shows how the WhereBuilder Object can be used:
var Fields = ['Id','Name','Phone','Address','Remarks','Discount'];
var Expression = WhereBuilder.createBinary( WhereBuilder.createField('Id'), WhereBuilder.createConstant('CustomValue'), 'Equal');
var result = lda.selectWhere('Customers',Fields,Expression,{});
Functions
createBinary(left, right, operator)
Creates a WhereBinary Object; use this to create a where binary expression, like field = 15
.
createUnary(value, operator)
Creates a WhereUnary Object, unary expressions are negations or binary NOT
operations.
createList(args...)
Creates a WhereList Object, lists are used with the IN
operator to determine if a value is in a list of others.
createParameter(name, type, size)
Creates a WhereParameter Object. Parameters are stored externally and can be used to pass blobs as where expressions.
createConstant(value, type)
Creates a WhereConstant Object. Constants can be any literal value.
createNull()
Creates a WhereNull Object. This represents the SQL null
construct.
createField(table, field)
Creates a WhereField Object. This is a reference to a field in the table in the table
parameter.
createMacro(name, args...)
Creates a WhereMacro Object. See the Macro Processor for more information on macros and when to use them.
createBetween(value, lower, upper)
Creates a WhereBetween Object. The value parameter will be compared to lower
and upper
, it has to be greater or equal to lower
, and less than or equal to upper
.