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

Prisma · Const

isNot

isNot excludes records whose related to-one record matches the supplied nested filter. It is used inside Prisma Client where clauses, such as filtering posts whose author is not named Bob.

How it works

Use isNot inside a Prisma Client where filter to exclude records whose related one-to-one record matches the supplied criteria. The nested object describes the related record that must not match; for example, isNot: { name: "Bob" } excludes posts authored by Bob.

Syntax

relation: { isNot: { field: value } }

Parameters

NameTypeDescription
filterobjectNested filter object describing the related record that must not match.

Returns

A Prisma Client query result containing parent records whose related record does not match the nested filter.

Key points

  • isNot is a Prisma Client option for filtering through a related record.
  • The documented relation use is for to-one relations, such as a post's author.
  • A nested condition can exclude parent records based on a related author's field value.
  • Use it when the parent query depends on properties of a related record.

Common mistakes

  • Use isNot for to-one relations; it is not the relation-list filter for to-many relations.

Example: Exclude records by a related record's fields

const posts = await prisma.post.findMany({
  where: {
    author: {
      isNot: { name: "Bob" },
    },
  },
});

Returns posts whose related author does not have the name Bob.

When to use it

Filter by a related author's fields

Exclude posts authored by a specific user.

Reject matching related records

Select parent records whose to-one relation does not satisfy a set of conditions.

Interview questions

QWhat does isNot do in a Prisma where clause?

isNot is a Prisma Client relation filter for excluding records whose related record matches nested criteria. For example, author: { isNot: { name: "Bob" } } returns posts whose author is not Bob.

Follow-up: How would you filter a relation-list instead? Use the list-relation filters documented for to-many relations, rather than the to-one isNot option.

QHow is the nested value of isNot interpreted?

Place isNot under a to-one relation field and provide the related record's field conditions as its value. Prisma returns parent records for which the related record does not satisfy those conditions.

Follow-up: What if the requirement is to exclude several different author conditions? Combine relation filters with Prisma's logical operators such as NOT, AND, or OR as appropriate.

QShow a practical isNot query.

A typical query is prisma.post.findMany({ where: { author: { isNot: { name: "Bob" } } } }). It filters posts according to properties of the related author and excludes matching authors.

Follow-up: Can isNot be used with composite types? Yes; Prisma's reference also documents it for composite fields, where it excludes composites that match the supplied object.

  • is
  • NOT
  • AND
  • OR

Source: Relation queries (Concepts) (Prisma ORM v7). Checked 2026-10-16.