Range Operators
Matches a field against a [min, max] range.
| Operator | SQL | Meaning |
|---|---|---|
between | BETWEEN ... AND ... | Value is within the range (inclusive) |
notBetween | NOT (... BETWEEN ... AND ...) | Value is outside the range |
between
typescript
{ where: { price: { between: [100, 500] } } }
// SQL: WHERE "price" BETWEEN 100 AND 500Notice: both bounds are inclusive.
Edge cases:
- The value must be a 2-element array
[min, max]; anything else throws[PostgresQueryOperators][BETWEEN] Invalid value: expected array of 2 elements, got .... - If either bound is
null, the condition matches no rows (SQLNULLcomparison). - If
min > max, the condition matches no rows.
notBetween
typescript
{ where: { score: { notBetween: [40, 60] } } }
// SQL: WHERE NOT ("score" BETWEEN 40 AND 60)Notice: matches values strictly outside the range.
Edge cases:
- Same 2-element array validation as
between, throwing[PostgresQueryOperators][NOT_BETWEEN] Invalid value: expected array of 2 elements, got .... - A
NULLcolumn matches neitherbetweennornotBetween.
See also
- Filter System Overview - the
filtershape and the fullwhereoperator table - Comparison Operators -
gt/gte/lt/lte, which can express the same range as an alternative tobetween/notBetween - Quick Reference - every operator, one line each
Files:
packages/connectors/src/relational/postgres/repositories/dialect/query.ts-PostgresQueryOperators.FNS, per-operator SQL builderspackages/connectors/src/relational/core/repositories/dialect/filter.ts-FilterBuilder, translatesTFilterto Drizzle/SQLpackages/filter/src/common/operators.ts-QueryOperatorsconstants