Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Const

not

Prisma's not filter excludes records whose scalar field matches a specified value or condition. On nullable fields, it does not include NULL rows unless an OR branch explicitly includes them.

How it works

Use not inside a scalar field filter to exclude records whose field matches a value or another supported condition. For nullable columns, the filter excludes NULL rows too; combine it with OR when NULL values must also be included.

Syntax

{ not: n }

Parameters

NameTypeDescription
nfield value or filter conditionThe value or supported field-filter condition that the field must not match.

Returns

A Prisma Client query result containing records whose field does not match the supplied value or condition.

Key points

  • The not filter selects records whose field value differs from the supplied value.
  • A common use is excluding records with one exact scalar value.
  • Use not inside the where object of a Prisma Client query.
  • Composite type fields use isNot, not the scalar not filter.

Common mistakes

  • On nullable columns, not does not include rows whose value is NULL.

Example: Exclude an exact value

const users = await prisma.user.findMany({
  where: {
    name: { not: "Eleanor" },
  },
});

This returns users whose name differs from the specified value.

When to use it

Exclude an exact match

Find records whose scalar field differs from a specified value.

Negate a field condition

Filter out records matching a supported string or scalar condition.

Handle nullable fields

Combine exclusion with a null branch when nullable data must remain in the result.

Interview questions

QWhat does Prisma's not filter do?

not is a field-level filter that selects records whose value does not equal the supplied value. For example, name: { not: "Eleanor" } excludes users named Eleanor.

Follow-up: How would you include NULL names too? Add an OR condition containing name: null alongside the not condition.

QWhat happens when not is used on a nullable field?

A nullable column's NULL values are not returned by a not filter. This follows SQL null semantics: NULL is not treated as an ordinary value that differs from the comparison value.

Follow-up: How can you test for records where the field is specifically NULL? Use a field filter with null, such as name: null.

QCan not exclude conditions other than equality?

not can be used with a field filter to exclude an exact value, while Prisma's broader filter operators can express negated conditions such as a value not containing a string. The exact syntax depends on the field's supported filter type.

Follow-up: How can multiple negated conditions be combined? Use the logical NOT operator for compound conditions.

  • OR
  • NOT
  • isNot
  • equals
  • contains

Source: Prisma Client API (Prisma ORM v7). Checked 2026-10-16.