Basics

Operators

Operator helpers are thin wrappers around op. Pass two statements for binary operators, one statement for unary operators, or none to emit the operator token for raw fragments.

Comparison

Equality and ordering helpers such as eq, ne,lt, lte, gt, and gte.

const query = q
  .select(q.c("users.id"))
  .from(q.t("users"))
  .where(q.eq(q.c("users.status"), q.v("active")))

Logical

Logical helpers such as is, isNot, andexclamation.

const query = q
  .select(q.c("users.id"))
  .from(q.t("users"))
  .where(q.is(q.c("users.deleted_at"), q.raw`NULL`))

Pattern Matching

LIKE/ILIKE and regex operators: like, ilike,notLike, matchRegex, and friends.

const query = q
  .select(q.c("users.email"))
  .from(q.t("users"))
  .where(q.ilike(q.c("users.email"), q.v("%@example.com")))

Bitwise

Bitwise helpers such as bitwiseAnd, bitwiseOr, and shift operators.

const query = q
  .select(q.c("flags.value"))
  .from(q.t("flags"))
  .where(q.bitwiseAnd(q.c("flags.value"), q.v(4)))

Arithmetic

Arithmetic helpers such as plus, minus,multiply, divide, and modulo.

const query = q
  .select(q.plus(q.c("orders.total"), q.v(10)))
  .from(q.t("orders"))

PostgreSQL Specific

PostgreSQL operator helpers such as atSign,hash, and caretAt.

const query = q
  .select(q.c("tags.label"))
  .from(q.t("tags"))
  .where(q.atSign(q.c("tags.label"), q.v("admin")))

Geometric

Geometric operators such as distance, closestPoint, and totalLength.

const query = q
  .select(q.c("places.id"))
  .from(q.t("places"))
  .orderBy(q.distance(q.c("places.location"), q.v("(0,0)")))

Between

Between helpers such as between, notBetween, and symmetric variants.

const query = q
  .select(q.c("events.created_at"))
  .from(q.t("events"))
  .where(q.between(q.v("2024-01-01"), q.v("2024-01-31")))

Operator Index

Complete list of operator helpers grouped by category.

Showing 15 of 60

#Operator HelperSQLGroup
1eq=Comparison
2ne<>Comparison
3notEq!=Comparison
4lt<Comparison
5gt>Comparison
6lte<=Comparison
7gte>=Comparison
8exclamation!Logical
9isISLogical
10isNotIS NOTLogical
11matchRegex~Pattern Matching
12matchRegexInsensitive~*Pattern Matching
13notMatchRegex!~Pattern Matching
14notMatchRegexInsensitive!~*Pattern Matching
15likeLIKEPattern Matching

Page 1 of 4