Queries

Excluding fields

Learn how to exclude fields from Prisma Client results with the omit option.

Use omit when you want Prisma Client to return the normal result shape except for a few specific fields.

Omit a field for one query

const user = await prisma.user.findUnique({
  where: { id: 1 },
  omit: {
    password: true,
  },
});

Omit fields globally

You can also configure omit on the client itself:

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

When to use omit vs select

  • Use select when you want to return only a small subset of fields.
  • Use omit when the default result is mostly correct and you only want to remove a few sensitive or noisy fields.

On this page