Skip to content

Commit

Permalink
update omit preview feature info
Browse files Browse the repository at this point in the history
  • Loading branch information
jharrell committed Jan 3, 2025
1 parent 1f77dd2 commit 316c52e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ By default Prisma Client returns all fields from a model. You can use `select` t

:::info

As of Prisma ORM 5.16.0, excluding fields globally and locally is supported via the `omitApi` Preview feature.
As of Prisma ORM 6.2.0, excluding fields globally and locally is supported. From versions 5.16.0 through 6.1.0, you must use the `omitApi` Preview feature.

:::

## Excluding a field globally using `omit`

The following is a type-safe way to exclude a field globally using the [`omitApi` Preview feature](/orm/reference/preview-features):
The following is a type-safe way to exclude a field globally:

<TabbedContent code>

Expand All @@ -23,7 +23,6 @@ The following is a type-safe way to exclude a field globally using the [`omitApi
```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["omitApi"]
}
model User {
Expand Down Expand Up @@ -60,7 +59,7 @@ const user = await prisma.user.findUnique({ where: { id: 1 } })

## Excluding a field locally using `omit`

The following is a type-safe way to exclude a field locally using the `omitApi` Preview feature:
The following is a type-safe way to exclude a field locally:

<TabbedContent code>

Expand All @@ -69,7 +68,6 @@ The following is a type-safe way to exclude a field locally using the `omitApi`
```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["omitApi"]
}
model User {
Expand Down Expand Up @@ -180,7 +178,7 @@ Local omit (when an `omit` option is provided in a query) only applies to the qu

:::note

The `omitApi` Preview feature, released in Prisma ORM 5.13.0, is the preferred way of omitting fields from a query result. The ability to globally omit fields was added to the `omitApi` Preview feature in Prisma ORM 5.16.0. This documentation is still relevant for versions of Prisma ORM prior to 5.13.0.
The `omitApi` feature, released in Preview in Prisma ORM 5.13.0 and Generally Available in Prisma ORM 6.2.0, is the preferred way of omitting fields from a query result. This documentation is still relevant for versions of Prisma ORM prior to 5.13.0.

:::

Expand Down
14 changes: 2 additions & 12 deletions content/200-orm/500-reference/050-prisma-client-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1932,24 +1932,14 @@ const usersWithCount = await prisma.user.findMany({
</cmdResult>
</CodeWithResult>

### `omit` (Preview)
### `omit`

`omit` defines which fields are excluded in the object that Prisma Client returns.

Because the `omit` option is currently in Preview, you need to enable it via the `omitApi` preview feature flag in your Prisma schema file:

```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["omitApi"]
}
```

After adding this flag, you need to run `prisma generate` again to re-generate Prisma Client.

#### Remarks

- You cannot combine `omit` and `select` since they serve opposite purposes
- `omit` was released into General Availability with Prisma ORM 6.2.0. It was available via the `omitApi` [Preview feature](/orm/reference/preview-features/client-preview-features) in Prisma ORM versions `5.13.0` through `6.1.0`.

#### Examples

Expand Down
Loading

0 comments on commit 316c52e

Please sign in to comment.