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

Prisma · Pipe

omit

Prisma Client's omit option excludes selected model fields from returned results. It can be applied globally on the client or locally to one query, making it useful for hiding sensitive fields such as passwords.

Since
6.2.0

How it works

omit removes named fields from Prisma Client result objects. Configure it when constructing the client for a model-wide default, or place it in one query to affect only that operation; this is useful when most fields are wanted but a few should be hidden.

Syntax

omit: { fieldName: true }

Parameters

NameTypeDescription
omitXOR<UserOmit, null>Object whose field names map to boolean values indicating which result fields to exclude; at client scope it is grouped by model.

Returns

A Prisma Client result object without the fields marked for omission.

Key points

  • Use omit when the usual result is appropriate except for a small set of fields.
  • A client-level configuration establishes default exclusions for the model.
  • Exclude several fields by adding separate entries to the same option.
  • A global password exclusion protects every query made through the configured client.
  • A local option limits the exclusion to one operation.

Common mistakes

  • A query-level omission does not carry over to later queries; configure the client globally when the exclusion must be consistent.
  • A global omission can be changed by an explicit selection or an overriding omission.

Example: Globally omit a sensitive field

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient({
  omit: {
    user: { password: true },
  },
})

async function main() {
  const user = await prisma.user.findUnique({ where: { id: 1 } })
  console.log(user) // password is excluded
}

main().finally(() => prisma.$disconnect())

Creates a Prisma Client that excludes the password field from every User query.

When to use it

Hide sensitive fields

A User model contains passwords or other secrets that should not appear in ordinary query results.

Trim mostly-complete results

Most model properties are needed, but a few internal or noisy properties should be removed from a response.

Apply a local exclusion

An individual endpoint needs a narrower result without changing the client's default behavior.

Interview questions

QWhat problem does omit solve, and when should it be used instead of select?

omit specifies fields that Prisma Client excludes from returned objects. It is the better choice when the normal model result is mostly needed and only a small number of fields should be removed.

Follow-up: When would select be preferable? Use select when only a small subset of fields is needed rather than when most fields should remain.

QHow do you configure a global omission?

Put omit in the Prisma Client constructor with a model-to-fields map. That exclusion applies to queries made through that client instance.

Follow-up: How can one query re-include a globally omitted field? Supply an overriding query option or use a specific select, as documented.

QHow do you exclude a field for only one query?

Add omit to an individual query and set each field to true. The exclusion then applies only to that query.

Follow-up: How do you omit several fields? Add multiple field-and-true entries to the same omit object.

  • select
  • PrismaClient
  • findUnique
  • findMany
  • UserOmit

Source: Excluding fields | Prisma Documentation. Checked 2026-10-16.