Learn about everything that has happened in the Prisma ecosystem and community from October to December 2021.
Overview
- Releases & new features
- Community
- Videos, livestreams & more
- We are hiring
- Stickers
- What's next?
Releases & new features
Our engineers have been hard at work issuing new releases with many improvements and new features every two weeks. Here is an overview of the most exciting features that we've launched in the last three months.
You can stay up-to-date about all upcoming features on our roadmap.
MongoDB introspection
In version 3.2.0
, we introduce support for introspecting MongoDB databases. If adding Prisma to an existing project, running prisma db pull
against a MongoDB database with existing data will sample the data and create a Prisma data model based on the stored documents.
Since 3.4.0
, introspection also works with embedded documents.
Cascading deletes and updates (referential actions)
Cascading deletes and updates (aka referential actions) are features that allow you to control how relations are handled when an entity with relations is changed or deleted. Typically this is done when defining the database schema using SQL.
Referential actions allows you to define this behavior from the Prisma schema by passing in the onDelete
and onUpdate
arguments to the @relation
attribute.
For example:
model LitterBox { id Int @id @default(autoincrement()) cats Cat[] full Boolean @default(false)}
model Cat { id String @id @default(uuid()) boxId Int box LitterBox @relation(fields: [boxId], references: [id], onDelete: Restrict)}
Here, you would not be able to delete a LitterBox
as long as there still is a Cat
linked to it in your database, because of the onDelete: Restrict
annotation. If we had written onDelete: Cascade
, deleting a LitterBox
would also automatically delete the Cat
s linked to it.
Referential actions was first released in in 2.26.0 with the referentialActions
Preview flag. Since then, we've worked to stabilize the feature.
Today, we're delighted to announce that Referential Actions is now General Available, meaning it is enabled by default.
On PostgreSQL, MySQL, SQLite and Microsoft SQL Server, referential actions will be enforced by the database.
Since 3.7.0
, this is also available on MongoDB.
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 }
Expanded index capabilities
In 3.6.0
, we released fulltext index support for MySQL and MongoDB as well as hash index support for PostgreSQL, both in Preview.
Here are examples for using the fulltext index on MySQL:
generator js { provider = "prisma-client-js" previewFeatures = ["fullTextIndex"]}
model Post { id Int @id title String @db.VarChar(255) content String @db.Text
@@fulltext([title, content])}
In 3.5.0
, we also released more configuration options for indexes and constraints in the Prisma schema.
This applies to:
- indexes
- unique constraints
- primary key constraints
These new configuration options come with full support for the prisma db pull
, prisma db push
and prisma migrate dev
commands, so index configuration can now be managed, evolved and deployed using Prisma's schema management tooling.
Two new arguments can now be specified per field:
length
(the maximum length of items in the index)sort
(how an index is sorted)
In order to use these new capabilities, add the extendedIndexes
feature flag in the generator block:
generator client { provider = "prisma-client-js" previewFeatures = ["extendedIndexes"]}
The change affects the @id
, @@id
, @unique
, @@unique
and @@index
fields in certain databases:
- The
length
argument is available on MySQL on the@id
,@@id
,@unique
,@@unique
and@@index
fields. It allows Prisma to now support indexes and constraints onString
with aTEXT
native type andBytes
types. - The
sort
argument is available for all databases on the@unique
,@@unique
and@@index
fields. Additionally, SQL Server also allows it on@id
and@@id
.
The following example demonstrates the use of the sort
and length
arguments:
model Post { title String @db.VarChar(300) abstract String @db.VarChar(3000) slug String @db.VarChar(3000) @unique(sort: Desc, length: 42) author String created_at DateTime
@@id([title(length: 100, sort: Desc), abstract(length: 10)]) @@index([author, created_at(sort: Desc)])}
Learn more in the documentation on index configuration.
VS Code extension now uses a Wasm module
Before version 3.6.0
, the language server powering the Prisma VS Code extension relied on logic from the Prisma engines in the form of a native binary. Downloading and running the native binary required a large amount of custom logic and led to problems due to network failures, operating system permissions and malicious code detection issues.
Starting with this release, the language server and the VS Code extension use logic compiled to WebAssembly and distributed through npm. There is no runtime binary download and no external process involved anymore. We expect this new distribution model to be more robust and hence provide a better experience for our users.
If you have any feedback, please leave an issue in the prisma/language-tools
repository.
Running Prisma Client in Cloudflare Workers
Using this new feature in Prisma Client and leveraging the Prisma Data Proxy, developers can now deploy Prisma applications on Cloudflare Workers. Here's what it looks like to use Prisma Client inside of this environment:
import { PrismaClient } from '@prisma/client'const prisma = new PrismaClient()
addEventListener('fetch', (event) => { event.respondWith(handleRequest(event.request))})
async function handleRequest(request: Request): Promise<Response> { await prisma.log.create({ data: { level: 'Info', message: `${request.method} ${request.url}`, }, }) return new Response(`request method: ${request.method}!`)}
Follow this deployment guide to learn how to use Prisma Client with your own Cloudflare Workers. If you run into any problems, you can reach us in this issue!
Solving connection management for serverless environments with the Data Proxy
The Prisma Data Proxy is an intermediary between your app and your database. It manages connection pooling, so you can reliably use traditional databases in Serverless environments.
Users can configure a Data Proxy for free on the Prisma Data Platform and connect their Prisma applications to the proxy by enabling the feature flag for it in their code.
For detailed documentation and instructions please refer to pris.ly/data-proxy.
New features for the Prisma Client API
Bytes
can now be filtered with in
and notIn
You can now use in
and notIn
operations on the Bytes
type:
const audioTracks = raws.map(raw => { return Buffer.from(raw)})
const result = await prisma.audio.find({ where: { track: in: audioTracks } }})
Get the count of a relation in MongoDB
This release, we're giving MongoDB developers the ability to query the count of a relation. In the example below, we're getting the number of posts each user wrote:
const userWithPostsCount = await prisma.user.findMany({ include: { _count: { select: { posts: true }, }, },})
// => [// {// email: "alice@prisma.io",// _count: { posts: 3 }// }// ]
Json
fields now accept read-only types
This is a small quality-of-life improvement. You can now pass immutable values into Json
fields. In the following example, audit
is a Json
field that accepts a read-only array:
const trail = [ { event: "signup" }, { event: "subscribe" }, { event: "invite friend" }] as const
await prisma.user.create({ data: { audit: trail }})
Community
We wouldn't be where we are today without our amazing community of developers. Our Slack has almost 50k members and is a great place to ask questions, share feedback and initiate discussions all around Prisma.
Join Slack
Meetups
Prisma Serverless Data Conference
In November, we hosted our first Serverless Data Conference. If you haven't yet, check out the talks on YouTube!
Watch Keynote
For this conference, we invited speakers from leading serverless companies such as Cloudflare, Vercel and Netlify to talk about how greatly Prisma fits into the serverless ecosystem. We also had several speakers from modern database companies, such as MongoDB, CockroachDB and PlanetScale.
Here is an overview of all the talks:
Opening Keynote - Søren Bramer Schmidt & Team
Building Applications At The Edge For Fun And Profit - Greg McKeon (Cloudflare)
Serverless Apps At Scale With Prisma Data Proxy And MongoDB Atlas Serverless - Kevin Jernigan (MongoDB)
Scaling Databases For Serverless World: A Chat With Sugu Sougoumarane - Taylor Barnett & Sugu Sougoumarane (Planetscale)
Building Serverless Apps With Next.Js And Prisma - Hassan El Mghari (Vercel)
Deploy A Serverless Prisma + PlanetScale React TypeScript App To Netlify - Jason Lengstorf (Netlify)
Server less, Code more - Aydrian Howard (CockroachDB)
Videos, livestreams & more
What's new in Prisma
Every other Thursday, Daniel Norman, Nikolas Burk and Alex Ruheni discuss the latest Prisma release and other news from the Prisma ecosystem and community. If you want to travel back in time and learn about a past release, you can find all the shows from this quarter here:
Some highlights of this quarter include the interviews with Prisma Ambassador Albin Groen about the Prisma Schema Builder, Serghei Ghidora about how Elsevier uses Prisma or Tana Berry, Prisma's new documentation lead.
Interviews
We published a lot of videos during this quarter on our YouTube channel, make sure you check them out and subscribe to not miss out on future videos.
This quarter, we also recorded a number of interviews with Prisma employees:
- Carmen Berndt (Software Engineer)
- Emily Morgan (Software Engineer)
- Tasin Ishman (Developer Success)
- Mahmoud Abdelwahab (Developer Advocate)
Also check out this interview with our community member Shanon Jackson about end-to-end type safety with Next.js and Prisma:
Be sure to subscribe to our YouTube channel to not miss any videos in the future:
Subscribe on YouTube
Written content
During this quarter, we published several technical articles on the Data Guide that you might find useful:
- Working with dates in PostgreSQL
- What is serverless?
- Serverless Glossary
- Introduction to common serverless challenges
- Introduction to Database replication and its benefits
- Top 13 serverless computing and database providers
We also published three success stories of companies adopting Prisma:
- How Tryg has leveraged Prisma to democratize data
- How Panther champions talent over geography with Prisma
- How Elsevier Piloted an Innovative Publication Process Quickly and Flexibly with Prisma
We also published several useful articles on our blog:
- Type-safe JavaScript with JsDoc
- Improving the Prisma Visual Studio Code Extension with WebAssembly
- Database Access in Serverless Environments with the Prisma Data Proxy
Prisma appearances
This quarter, several Prisma folks have appeared on external channels and livestreams. Here's an overview of all of them:
Daniel Norman @ Next.js Conf
Mahmoud Abdelwahab @ Next.js Conf
Daniel Norman @ MongoDB Podcast
We are hiring
Also, we're hiring for various roles! If you're interested in joining us and becoming a Prismate, check out our jobs page.
Explore Jobs
Stickers
We love seeing laptops that are decorated with Prisma stickers, so we're shipping them for free to our community members! In this quarter, we've sent out over 3500(!) sticker packs to developers that are excited about Prisma!
Order Stickers
What's next?
The best places to stay up-to-date about what we're currently working on are GitHub issues and our public roadmap.
You can also engage in conversations in our Slack channel, start a discussion on GitHub or join one of the many Prisma meetups around the world.
If you never want to miss any news from the Prisma community, follow us on Twitter.