DbQueryTableColumnComparison - do-/node-doix-db GitHub Wiki
DbQueryTableColumnComparison
is a class representing simplest SQL comparison predicates:
<table name>.<column name> <comp op> <value>
For IN
and NOT IN
operators:
- when an empty array is passed as
value
, table and column names are ignored and the whole expression is replaced by0=1
forIN
(in empty set == false) and0=0
forNOT IN
- a
{sql, params}
object can be used asvalue
: in this case, the...IN (${sql})
fragment is generated andparams
are bound appropriately.- a single column DbQuery is suitable on this occasion.
Name | Type | Description |
---|---|---|
table |
DbQueryTable | The table this predicate is associated to |
column |
DbColumn | The column which value is compared (left side) |
op |
String | Comparison operator name, uppercase |
sql |
String | The SQL fragment to be interpolated in the query |
params |
Array | The list of parameters corresponding to all ? placeholders in sql
|
const myComp = new DbQueryTableColumnComparison (myQueryTable, 'id', 'IN', [1, 2])
Using DbQueryTable's createColumnComparison method is encouraged.
const myComp = myQueryTable.createColumnComparison ('id', 'IN', [1, 2])
Name | Type | Description |
---|---|---|
table |
DbQueryTable | The table this predicate is associated to |
name |
String |
column 's name. |
op |
String | Comparison operator name, any case |
value |
any | The value(s) the column is compared to. Ignored for unary operators. |
This internal method, called from the constructor, sets sql
and params
based on incoming op
and value
.