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
},
},
},
})
Expand to view the example Prisma schema
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
}
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
- MySQL
upsert()
:Internal error: Attempted to serialize empty result.
- Mysql
upsert()
fails with "Attempted to serialize empty result." - Interactive Transaction API timing out after upgrading from 4.7.0 and above
- MySQL and SQLite
upsert()
:Internal error: Attempted to serialize empty result.
- MySQL
upsert()
:Internal error: Attempted to serialize empty result.
- MongoDB
upsert()
:Internal error: Attempted to serialize empty result.
- MongoDB
upsert()
:Internal error: Attempted to serialize empty result
- Relation mode +
upsert()
:Internal error: Attempted to serialize empty result.
Internal error: Attempted to serialize empty result.
onupsert()
forupdate
case in different databases (when usingrelationMode=prisma
explicitly or implicitly [MongoDB])- Postgres
upsert(): Internal error: Attempted to serialize empty result
whenrelationMode = "prisma"
is used ✘ [ERROR] near "��": syntax error at offset 0
when runningwrangler d1 migrations apply
with Prisma generated migration (on Windows, using Powershell)
Credits
Huge thanks to @ospfranco, @pranayat, @yubrot, @skyzh, @anuraaga, @yehonatanz, @arthurfiorette, @elithrar, @tockn, @Kuhave, @obiwac for helping!