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

Prisma · Const

notIn

notIn excludes records whose scalar field matches any value in a supplied list. Use it as a nested field filter in Prisma Client queries.

How it works

Use notIn inside a scalar field filter to exclude records whose field value matches any value in the supplied list. It is useful when the unwanted values are known as an array, and it can be combined with other conditions in a where object.

Syntax

{ field: { notIn: values } }

Parameters

NameTypeDescription
valuesScalar[]An array of scalar values to exclude from the selected field.

Returns

A Prisma Client query result containing records whose filtered field is not equal to any supplied value.

Key points

  • notIn is used within Prisma Client's where filtering API to restrict which records a query returns.
  • It is a field-level filter condition and operator, alongside other scalar filtering operators documented in the Prisma Client reference.
  • The filter can be combined with logical operators such as AND, OR, and NOT when a query needs compound conditions.

Example: Exclude matching values

const users = await prisma.user.findMany({
  where: {
    id: { notIn: [1, 2, 3] },
  },
});

This query returns users whose id is not one of the listed values.

When to use it

Omit records with selected IDs

Exclude known identifiers

Remove several statuses from results

Filter lifecycle values

Combine exclusion with logical conditions

Build compound queries

Interview questions

QWhat does the notIn filter do?

notIn is a Prisma Client scalar filter that excludes records whose field equals any value in the provided list. For example, id: { notIn: [1, 2, 3] } omits those IDs.

Follow-up: How would you combine exclusion with another condition? Put notIn inside the field's filter object and add the other field conditions under the same where object.

QHow do you write a notIn condition?

Use the object form of the filter: where: { status: { notIn: ["ARCHIVED", "DELETED"] } }. This expresses the excluded values explicitly and works with Prisma Client's filter syntax.

Follow-up: Why should an older array shortcut not be used? Prisma ORM 5 removed the in and notIn shortcuts, so the nested filter form is required.

QHow does notIn differ from NOT?

notIn is appropriate when exclusion is based on a finite list of scalar values. It differs from NOT, which is a logical operator for negating a broader condition or grouping conditions.

Follow-up: When would NOT be preferable? Use NOT when negating another filter expression rather than simply excluding listed scalar values.

  • in
  • not
  • AND
  • OR
  • NOT

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