In
Set-membership comparison (left in (right...)). Extends CompOperator.
Shorthand keys: in; also the implicit default when an object-literal value is an array with no
explicit suffix (see below).
Constructor
In(left: string | SqlElement, right: any[] | SqlElement): In
new In(left: string | SqlElement, right: any[] | SqlElement): In
Dual-callable. A non-array, non-SqlElement right is wrapped in a single-element array.
import { In, Select } from '@sqb/builder';
Select().from('customers').where(In('id', [1, 2, 3]));
// where id in (1,2,3)
An empty array is special-cased to avoid silently dropping the filter: In('id', []) serializes
to the literal 1=0 (always false) instead of an empty in ().
Properties
Inherits every property from CompOperator (_type, _left, _right,
_symbol, _isArray); _symbol is always 'in'.
Methods
In overrides _serialize() to special-case an empty _right array (see above), falling back to
CompOperator's default rendering otherwise; it adds no
chainable methods of its own.
Object-literal shorthand
An array value with no explicit operator suffix builds an In (rather than an Eq comparing to
the array itself):
Select().from('customers').where({ age: [18, 19, 20], 'status in': ['active', 'trial'] });
// where age in (18,19,20) and status in ('active','trial')