Alex Ruheni
3.7.0
prisma rainbow
🧪 Referential actions support for MongoDB
In 3.7.0
, we’ve added MongoDB support for onDelete
and onUpdate
to specify how you want to handle changes to relationships. MongoDB does not support referential actions out of the box, but we can emulate this feature inside the Prisma Query Engine. Given the following schema:
model User {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
posts Post[]
name String
}
model Post {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
author User @relation(fields: [userId], references: [id], *onDelete: Cascade*)
title String
userId String @db.ObjectId
}
By specifying onDelete: Cascade
, Prisma will also delete posts whenever the author of the posts is deleted. There’s a lot more to referential actions than cascading deletes. Head over to our documentation to learn more. Prisma exposes features and workflows that database vendors don’t offer.
🔁 Prevent referential cycles on MongoDB
As part of getting onDelete
and onUpdate
ready for MongoDB, we’ve tightened up our validation rules to prevent a potential stack overflow if you create a loop with referential actions.
This change may cause some existing schemas using the mongodb
preview feature to become invalid, where your schema now errors out with the following message:
Error parsing attribute "@relation": Reference causes a cycle.
If you run into this, you can learn how to resolve it with this documentation. If you’re still stuck, feel free to open a discussion, and we’ll lend a hand!
⚠️ Deprecating undocumented usage of type
in Prisma Schema
With Prisma 3.7.0
release, the VS Code extension (and other IDEs using our language server implementation) will start to show a warning when detecting unsupported usage of the type
keyword. We plan to remove that functionality entirely with the next major release of Prisma. If you depend on similar functionality for type aliasing, please comment on the issue. Here’s an example of a string alias:
type MyId = String @id @default(dbgenerated(new_uuid()))
model A {
id MyId
}
🔒 Prisma Studio improvements
• Due to how Prisma Studio executes Prisma Client queries, it was possible to execute arbitrary code on Studio’s local server. This has since been patched.
• Issues with viewing and updating models with BigInt
fields are also resolved.
📚 Learn more in the release notes
For more info and links to documentation, you can read the release notes.
🌟 Help us spread the word about Prisma 🌟
To help spread the word about Prisma, we’d very much appreciate it if you would star the repo 🌟 And if you’re excited about the features in this week’s release, then help us and share your excitement on Twitter.
📰 Join us today for the “What’s new in Prisma” livestream
This week, @nikolasburk and @Alex Ruheni R. will discuss the latest release and other news from the Prisma ecosystem in a livestream on YouTube today at 5 pm Berlin | 8 am San Francisco.