Prisma: 5.13.0 Release

Release date:
April 22, 2024
Previous version:
5.12.1 (released April 4, 2024)
Magnitude:
1,306 Diff Delta
Contributors:
8 total committers
Data confidence:
Commits:

44 Commits in this Release

Ordered by the degree to which they evolved the repo in this version.

Authored April 22, 2024

Top Contributors in 5.13.0

ospfranco
prisma-bot
Weakky
yehonatanz
Jolg42
janpio
SevInf
renovate-bot

Directory Browser for 5.13.0

All files are compared to previous version, 5.12.1. Click here to browse diffs between other versions.

Loading File Browser...

Release Notes Published

Today, we are excited to share the 5.13.0 stable release 🎉

🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release.

Highlights

omit fields from Prisma Client queries (Preview)

We’re excited to announce Preview support for the omit option within the Prisma Client query options. The highly-requested omit feature now allows you to exclude fields that you don’t want to retrieve from the database on a per-query basis.

By default, when a query returns records, the result includes all scalar fields of the models defined in the Prisma schema. select can be used to return specific fields, while omit can now be used to exclude specific fields. omit lives at the same API level and works on all of the same Prisma Client model queries as select. Note, however, that omit and select are mutually exclusive. In other words, you can’t use both in the same query.

To get started using omit, enable the omitApi Preview feature in your Prisma schema:

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["omitApi"]
}

Be sure to re-generate Prisma Client afterwards:

npx prisma generate

Here is an example of using omit:

// Includes all fields except password
await prisma.user.findMany({
  omit: {
   password: true
  },
})

Here is an example of using omit with include:

// Includes all user fields except user's password and title of user's posts
await prisma.user.findMany({
  omit: {
   password: true
  },
  include: {
    posts: {
      omit: {
        title: true
      },
    },
  },
})

<details> <summary>Expand to view the example Prisma schema</summary>

model User {
  id       Int     @id @default(autoincrement())
  email    String  @unique
  name     String?
  password String
  posts    Post[]
}

model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int
}

</details>

Many users have requested a global implementation of omit. This request will be accommodated in the future. In the meantime, you can follow the issue here.

📣 Share your feedback: omitApi Preview feature

📚 Documentation: omit - Prisma Client API Reference

Fixes and improvements

Prisma Migrate

Prisma Client

Credits

Huge thanks to @ospfranco, @pranayat, @yubrot, @skyzh, @anuraaga, @yehonatanz, @arthurfiorette, @elithrar, @tockn, @Kuhave, @obiwac for helping!