Between
Range comparison (left between right[0] and right[1]). Extends
CompOperator, overriding serialization to render two bound values.
Shorthand keys: between, btw.
Constructor
Between(left: string | SqlElement, right: any[] | SqlElement): Between
Between(left: string | SqlElement, right1: any, right2: any): Between
new Between(...): Between
Dual-callable, two argument forms — either an explicit [lower, upper] array/tuple, or two
separate bound arguments. If the upper bound is null/undefined, it's set equal to the lower
bound (so a single value repeats on both sides).
import { Between, Select } from '@sqb/builder';
Select().from('customers').where(Between('id', 10, 20));
// where id between 10 and 20
Between('id', [10, 20]); // same, as an array
Between('id', [10]); // id between 10 and 10
Serializes to an empty string if right is empty (e.g. Between('id', [])).
Properties
Inherits every property from CompOperator (_type, _left, _right,
_symbol, _isArray); _symbol is always 'between' and _right is always a two-element array.
Methods
Between overrides _serialize()/__defaultSerialize() to render both bounds
(<left> between <right[0]> and <right[1]>); it adds no chainable methods of its own.
Object-literal shorthand
Select().from('customers').where({ 'id between': [10, 20], 'age btw': [18, 30] });
// where id between 10 and 20 and age between 18 and 30