Or
Combines any number of operators, Raw fragments, or nested And/Or groups with or. Extends
LogicalOperator. Shorthand key: or (as an object-literal property,
case-insensitive — see below).
Constructor
Or(...expressions: any[]): Or
new Or(...expressions: any[]): Or
Dual-callable. expressions are forwarded to .add() — see
LogicalOperator#add() for accepted argument types, including the
object-literal shorthand.
import { Or, And, Eq, Select } from '@sqb/builder';
Select().from('customers').where(Or(And(Eq('id', 1), Eq('id', 2)), Eq('id', 3)));
// where ((id = 1 and id = 2) or id = 3)
Properties
Inherits every property from LogicalOperator (_type, _items); its
_operatorType is always OperatorType.or.
Methods
Inherits .add() from LogicalOperator;
Or adds no methods of its own.
Object-literal shorthand
The or key (case-insensitive) in a plain object passed to .where()/.add()/And(...) is
special-cased to build an Or from an array of sub-conditions:
Select().from('customers').where({ OR: [{ id: 1 }, { id: 2 }] });
// where (id = 1 or id = 2)