Skip to content

Range Operators

Matches a field against a [min, max] range.

OperatorSQLMeaning
betweenBETWEEN ... AND ...Value is within the range (inclusive)
notBetweenNOT (... BETWEEN ... AND ...)Value is outside the range

between

typescript
{ where: { price: { between: [100, 500] } } }
// SQL: WHERE "price" BETWEEN 100 AND 500

Notice: 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 (SQL NULL comparison).
  • 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 NULL column matches neither between nor notBetween.

See also

Files: