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