Skip to content

Null Check Operators

Checks whether a field is NULL or has a value, without comparing to a specific value.

OperatorSQLMeaning
isIS NULL / =Null check or equality
isnIS NOT NULL / !=Not-null check or inequality
existsIS NOT NULL / IS NULLPresence check
notExistsIS NULL / IS NOT NULLInverse presence check

is

typescript
{ where: { deletedAt: { is: null } } }
// SQL: WHERE "deleted_at" IS NULL

Notice: is behaves exactly like eq - is: null compiles to IS NULL, is: <value> compiles to =.

Edge cases:

  • The bare shorthand { deletedAt: null } (no operator key) is identical to { deletedAt: { is: null } }.
  • { is: 'active' } compiles to "status" = 'active', the same as eq.

isn

typescript
{ where: { verifiedAt: { isn: null } } }
// SQL: WHERE "verified_at" IS NOT NULL

Notice: isn behaves exactly like ne/neq - isn: null compiles to IS NOT NULL, isn: <value> compiles to !=.

Edge cases:

  • Same three-valued-logic caveat as ne: { isn: value } for a real value never matches a NULL row.

exists

typescript
{ where: { verifiedAt: { exists: true } } }
// SQL: WHERE "verified_at" IS NOT NULL

Notice: exists takes a boolean, not a value - exists: false compiles to IS NULL, anything else compiles to IS NOT NULL.

Edge cases:

  • Only the literal false selects the IS NULL branch.
  • Any other operand, including 0 or a truthy string, selects IS NOT NULL.
  • Also works over a JSON path key, for example { 'metadata.score': { exists: true } }.

notExists

typescript
{ where: { verifiedAt: { notExists: true } } }
// SQL: WHERE "verified_at" IS NULL

Notice: the inverse of exists - notExists: false compiles to IS NOT NULL, anything else compiles to IS NULL.

Edge cases:

  • Same false-only branch rule as exists.

See also

Files: