# What's new in Prisma? (Q1/21) URL: https://www.prisma.io/blog/whats-new-in-prisma-q1-2021-spjyqp0e2rk1 Published: 2021-03-31 Authors: Nikolas Burk Tags: announcement Description: Learn about everything that has happened in the Prisma ecosystem and community from January to March 2021. > Blog posts describe Prisma as it was on the date shown and are not kept current. Before implementing from a post, check the documentation index at https://www.prisma.io/docs/llms.txt and the changelog at https://www.prisma.io/changelog.md. > For an index of every published post, fetch https://www.prisma.io/blog/llms.txt. Learn about everything that has happened in the Prisma ecosystem and community from January to March 2021. ## Overview [#overview] * [Releases & new features](#releases--new-features) * [Prisma Migrate is generally available 🚀](#prisma-migrate-is-generally-available-) * [Use native database types in the Prisma schema](#use-native-database-types-in-the-prisma-schema) * [Seed your database with the Prisma CLI (Preview)](#seed-your-database-with-the-prisma-cli-preview) * [New features for the Prisma Client API](#new-features-for-the-prisma-client-api) * [Order by relations (Preview)](#order-by-relations-preview) * [Count on relations (Preview)](#count-on-relations-preview) * [Efficient bulk creates with `createMany`](#efficient-bulk-creates-with-createmany) * [Directly set foreign keys](#directly-set-foreign-keys) * [Group by](#group-by) * [Reducing overhead between Node.js and Rust with N-API (Preview)](#reducing-overhead-between-nodejs-and-rust-with-n-api-preview) * [New features for Prisma Client Go](#new-features-for-prisma-client-go) * [Tools & ecosystem](#tools--ecosystem) * [Blitz](#blitz) * [KeystoneJS](#keystonejs) * [Wasp](#wasp) * [Amplication](#amplication) * [`prisma-appsync` generator](#prisma-appsync-generator) * [Bedrock SaaS Template by Max Stoiber](#bedrock-saas-template-by-max-stoiber) * [Community](#community) * [Meetups](#meetups) * [Prisma Enterprise Event](#prisma-enterprise-event) * [Stickers](#stickers) * [Videos, livestreams & more](#videos-livestreams--more) * [What's new in Prisma](#whats-new-in-prisma) * [Videos](#videos) * [Prisma appearances](#prisma-appearances) * [New Prismates](#new-prismates) * [What's next?](#whats-next) ## Releases & new features [#releases--new-features] Our engineers have been hard at work issuing new [releases](https://github.com/prisma/orm/releases/) with many improvements and new features every two weeks. Here is an overview of the most exciting features that we have launched in the last three months. You can stay up-to-date about all upcoming features on our [roadmap](https://pris.ly/roadmap). ### Prisma Migrate is generally available 🚀 [#prisma-migrate-is-generally-available-] The biggest news in this quarter certainly was the launch of Prisma Migrate for [General Availability](https://www.prisma.io/docs/orm/v7/more/releases#generally-available-ga). This means, you can now use Prisma Migrate without the `--preview-feature` option: **Before v2.19.0** ``` npx prisma migrate --preview-feature # for example: npx prisma migrate dev --preview-feature ``` **Now** ``` npx prisma migrate # for example: npx prisma migrate dev ``` You can learn more about this in the [release notes](https://github.com/prisma/orm/releases/tag/2.19.0), the [announcement article](https://www.prisma.io/blog/prisma-migrate-ga-b5eno5g08d0b) and the [video demo](https://www.youtube.com/watch?v=Ac-HWBTtLAU\&t=51s\&ab_channel=Prisma) by [Daniel](https://twitter.com/daniel2color) and [Tom](https://twitter.com/_tomhoule). ### Use native database types in the Prisma schema [#use-native-database-types-in-the-prisma-schema] In this quarter, we made it possible to use a much broader range of native database types in the Prisma schema. For example, you can now define `VARCHAR` types of a specific length or use other database-specific types like (in this case for PostgreSQL) `MONEY`, variations of date/time types like `TIME`, `TIMETZ` or `TIMESTAMPTZ` and a lot more. Here's an example: ```prisma datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id Int @id @default(autoincrement()) @db.Integer email String @unique @db.VarChar(191) birthday DateTime? @db.Timestamptz wealth Decimal @db.Money } ``` ```sql CREATE TABLE "User" ( "id" SERIAL NOT NULL, "email" VARCHAR(191) NOT NULL, "birthday" TIMESTAMPTZ, "wealth" MONEY NOT NULL, PRIMARY KEY ("id") ); CREATE UNIQUE INDEX "User.email_unique" ON "User"("email"); ``` For a full overview of available types, check out the type mapping sections in the docs: * [PostgreSQL](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/postgresql#type-mapping-between-postgresql-to-prisma-schema) * [MySQL](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/mysql#type-mapping-between-mysql-to-prisma-schema) * [SQLite](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/sqlite#data-model-mapping) * [SQL Server](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/sql-server#type-mapping-between-microsoft-sql-server-to-prisma-schema) (Preview) ### Seed your database with the Prisma CLI (Preview) [#seed-your-database-with-the-prisma-cli-preview] The new [`prisma db seed`](https://www.prisma.io/docs/orm/v7/reference/prisma-cli-reference#db-seed-preview) command enables you to automatically [invoke a seed script](https://www.prisma.io/docs/orm/v7/prisma-migrate/workflows/seeding#set-up-seeding-in-typescript) to feed your database with some initial data. The command expects a file called `seed` with the respective file extension inside your main prisma directory: * JavaScript: `prisma/seed.js` * TypeScript: `prisma/seed.ts` * Shell: `prisma/seed.sh` Alternatively you can pass the `--schema` option to the CLI command in order to point to the location of the seed script or define a default `schema` location in your `package.json` which will be picked up every time you run the command. ### Expand to view a sample seed script ```ts // prisma/seed.ts import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() // A `main` function so that we can use async/await async function main() { const newUser = await prisma.user.create({ data: { email: 'sarah@prisma.io', }, }) console.log(`New user created`, newUser.id) } main() .catch(e => { console.error(e) process.exit(1) }) .finally(async () => { await prisma.$disconnect() }) ``` ### New features for the Prisma Client API [#new-features-for-the-prisma-client-api] We regularly add new features to the Prisma Client API to enable more powerful database queries that were previously only possible via plain SQL and the [`$queryRaw`](https://www.prisma.io/docs/orm/v7/prisma-client/using-raw-sql/raw-queries#queryraw) escape hatch . #### Order by relations (Preview) [#order-by-relations-preview] Since [2.16.0](https://github.com/prisma/orm/releases/tag/2.16.0), you can order the results of `findMany` queries by properties of [related](https://www.prisma.io/docs/orm/data-modeling/relational-databases) models. For example, you can order a list of posts alphabetically by the names of their authors: ```ts cons posts = await prisma.post.findMany({ orderBy: [ { author: { name: 'asc', }, }, ], }) ``` ```prisma model Post { id Int @id @default(autoincrement()) title String authorId Int author User @relation(fields: [authorId], references: [id]) } model User { id Int @id @default(autoincrement()) nam String posts Post[] } ``` Additionaly, the [2.19.0](https://github.com/prisma/orm/releases/tag/2.19.0) release makes it possible to order by the aggregates (e.g. count) of relations as well. Here's is an example that orders a list of users by the number of the posts they created: ```ts const users = await prisma.user.findMany({ orderBy: { posts: { count: 'asc', }, }, }) ``` ```prisma model Post { id Int @id @default(autoincrement()) title String authorId Int author User @relation(fields: [authorId], references: [id]) } model User { id Int @id @default(autoincrement()) nam String posts Post[] } ``` #### Count on relations (Preview) [#count-on-relations-preview] This [highly requested feature](https://github.com/prisma/orm/issues/5079) is now Preview since [2.20.0](https://github.com/prisma/orm/releases/tag/2.20.0). You can now count the number of related records by passing `_count` to the `select` or `include` options and then specifying which relation counts should be included in the resulting objects via another `select`. For example, counting the number of posts that an user has written: ```ts const users = await prisma.user.findMany({ include: { _count: { select: { posts: true }, }, }, }) ``` ```js { id: 1, email: 'alice@prisma.io', name: 'Alice', _count: { posts: 2 } } ``` #### Efficient bulk creates with `createMany` [#efficient-bulk-creates-with-createmany] The new `createMany` operation (introduced in [2.16.0](https://github.com/prisma/orm/releases/tag/2.16.0)) enables you to insert data a whole lot faster: ```ts const result = await prisma.user.createMany({ data: [ { email: 'alice@prisma.io' }, { email: 'nilu@prisma.io' }, { email: 'mahmoud@prisma.io' }, { email: 'etel@prisma.io' }, ], }) console.log(`Created ${result.count} users!`) ``` #### Directly set foreign keys [#directly-set-foreign-keys] Since [2.15.0](https://github.com/prisma/orm/releases/tag/2.16.0), it is possible to dirctly set foreign keys instead of wiring up relations via the `connect` API: ```ts // An example of the new API that directly sets the foreign key const user = await prisma.profile.create({ data: { bio: 'Hello World', userId: 42, }, }) // If you prefer, you can still use the previous API via `connect` const user = await prisma.profile.create({ data: { bio: 'Hello World', user: { connect: { id: 42 }, // sets userId of Profile record }, }, }) ``` #### Group by [#group-by] Since [2.14.0](https://github.com/prisma/orm/releases/tag/2.14.0), Prisma Client supports *group by* queries: ```ts const locations = await client.agent.groupBy({ by: ['location'], min: { rate: true, }, }) ``` ```js [ { location: "Los Angeles", min: { rate: 10.00 } }, { location: "London", min: { rate: 20.00 } }, { location: "Tokyo", min: { rate: 30.00 } } ] ``` ```prisma model Agent { id String @id name String location String rate Float } ``` Additionally, you can further filter the result by using the `having` option: ```ts const locations = await client.agent.groupBy({ by: ['location', 'rate'], min: { rate: true, }, having: { rate: { gte: 20, }, }, }) ``` ```js [ { location: "London", rate: 20.00, min: { rate: 20.00 } }, { location: "Tokyo", rate: 30.00, min: { rate: 30.00 } } ] ``` ```prisma model Agent { id String @id name String location String rate Float } ``` You can learn more about these queries in the [docs](https://www.prisma.io/docs/orm/fundamentals/reading-data). #### Reducing overhead between Node.js and Rust with N-API (Preview) [#reducing-overhead-between-nodejs-and-rust-with-n-api-preview] [N-API](https://napi.rs/) is a new technique for binding Prisma's Rust-based [query engine](https://www.prisma.io/docs/orm/v7/more/releases) directly to Prisma Client that was introduced in [2.20.0](https://github.com/prisma/orm/releases/tag/2.20.0). This reduces the communication overhead between the Node.js and Rust layers when resolving Prisma Client's database queries. Enabling the N-API will not affect your workflows in any way, the experience of using Prisma will remain exactly the same. The N-API has different runtime characteristics than the current communication layer between Node.js and Rust. There may be some rough edges during the Preview period. #### New features for Prisma Client Go [#new-features-for-prisma-client-go] In case you're not aware, [Prisma Client also is available for Golang](https://github.com/prisma/prisma-client-go) in an [Early Access](https://www.prisma.io/docs/orm/v7/more/releases#early-access) version. You can learn more about Prisma Client Go in the [documentation](https://github.com/prisma/prisma-client-go/tree/master/docs). Also note that we are actively looking for feedback for Prisma Client Go! You can help us accelerate the release process by [creating issues](https://github.com/prisma/prisma-client-go/issues) and sharing your feedback in the [`#prisma-client-go`](https://app.slack.com/client/T0MQBS8JG/C015HGAQZ0D) channel on the [Prisma Slack](https://slack.prisma.io). ### Expand to view the new Prisma Client Go features from this quarter This quarter, Prisma Client Go saw some exciting updates as well: *Upserts* ```go post, _ := client.Post.UpsertOne( // query Post.ID.Equals("upsert"), ).Create( // set these fields if document doesn't exist already Post.Title.Set("title"), Post.Views.Set(0), Post.ID.Set("upsert"), ).Update( // update these fields if document already exists Post.Title.Set("new-title"), Post.Views.Increment(1), ).Exec(ctx) ``` *Dynamic filters* ```go func CreateUser(w http.ResponseWriter, r *http.Request) { var params []db.UserSetParam email := r.PostFormValue("email") kind := r.PostFormValue("kind") if kind == "customer" { // Set the referrer for users of type customer only params = append(params, db.User.Referer.Set(r.Header.Get("Referer")) } user, err := client.User.CreateOne( db.User.Kind.Set(kind), db.User.Email.Set(email), params..., ).Exec(r.Context()) // ... Handle the response } ``` *Transactions* ```go createUserA := client.User.CreateOne( db.User.ID.Set("c"), db.User.Email.Set("a"), ) createUserB := client.User.CreateOne( db.User.ID.Set("d"), db.User.Email.Set("b"), ) err := client.Prisma.Transaction(createUserA, createUserB).Exec(ctx) if err != nil { return err } ``` *New types: `BigInt`, `Decimal` and `Bytes`* ```go var views db.BigInt = 1 bytes := []byte("abc") dec := decimal.NewFromFloat(1.23456789) created, err := client.User.CreateOne( db.User.Picture.Set(bytes), db.User.Balance.Set(dec), db.User.Views.Set(views), ).Exec(ctx) ``` *** ## Tools & ecosystem [#tools--ecosystem] ### Blitz [#blitz] We are excited for the [Blitz](https://blitzjs.com/) community to see them launch an official beta version of their framework, including a new website and documentation: [Post on X](https://x.com/i/status/1362048912476016642) Blitz is a batteries-included framework that's inspired by Ruby on Rails, is built on Next.js, and features a "Zero-API" data layer abstraction that eliminates the need for REST/GraphQL. It uses Prisma as its default ORM layer. ### KeystoneJS [#keystonejs] While it's already possible to use KeystoneJS with Prisma as the ORM, the [upcoming version of KeystoneJS](https://next.keystonejs.com/) will use Prisma as its default database adapter. KeystoneJS founder [Jed Watson](https://twitter.com/JedWatson) recently was a guest on the [What's new in Prisma](https://www.youtube.com/watch?v=Iwhb33vm5uk\&t=1902s\&ab_channel=Prisma) livestream where he gave a demo of KeystoneJS with Prisma. [Post on X](https://x.com/i/status/1362717932078383109) ### Wasp [#wasp] Backed by YCombinator, the twin brothers [Martin](https://twitter.com/MartinSosic) and [Matija](https://twitter.com/matijasosic) Šošić are building [Wasp](https://wasp-lang.dev/), a DSL for building fullstack web applications. They recently [launched Wasp on Hacker News](https://news.ycombinator.com/item?id=26091956). To learn more about Wasp, be sure to check out Matija's [talk](https://www.youtube.com/watch?v=p3PNKJKsSuU\&ab_channel=Prisma) at our recent Prisma Meetup: [Watch the video on YouTube](https://www.youtube.com/watch?v=p3PNKJKsSuU) ### Amplication [#amplication] [Amplication](https://github.com/amplication/amplication) is another exciting tool that promises to make web developers more productive, is built on Prisma and recently [launched on Hacker News](https://news.ycombinator.com/item?id=25749492). It allows to instantly generate fully-fledged REST and GraphQL APIs. The projects are configured via a web UI but can be fully customized as the underlying NestJS app can be downloaded and edited by the developer. ### `prisma-appsync` generator [#prisma-appsync-generator] [Sylvain Simao](https://linktr.ee/maoosi) recentely released a first version of [`prisma-appsync`](https://github.com/maoosi/prisma-appsync), a custom `generator` for the Prisma schema that enables developer to generate a full-blown GraphQL CRUD API via AWS AppSync and deployable with single command of the AWS CDK. To learn more, check out the [documentation](https://prisma-appsync.vercel.app/) and watch our recent [What's new in Prisma](https://www.youtube.com/watch?v=Ac-HWBTtLAU\&t=494s\&ab_channel=Prisma) episode. ### Expand to learn about other community generators Our community has built custom generators for the following use cases: * [`prisma-docs-generator`](https://github.com/pantharshit00/prisma-docs-generator): Individual Prisma Client API reference * [`prisma-dbml-generator`](https://notiz.dev/blog/prisma-dbml-generator#dbml-generator): DBML diagrams to visualize the Prisma schema * [`typegraphql-prisma`](https://github.com/MichalLytek/typegraphql-prisma#readme): CRUD resolvers for TypeGraphQL * [`prisma-json-schema-generator`](https://github.com/pantharshit00/prisma-docs-generator): Prisma schema into JSON schema ### Bedrock SaaS Template by Max Stoiber [#bedrock-saas-template-by-max-stoiber] [Max Stoiber](https://mxstbr.com/) is well-known in the JavaScript community for his popular open source work, like [`styled-components`](https://github.com/styled-components/styled-components) and [`react-boilerplate`](https://github.com/react-boilerplate/react-boilerplate). He recently announced [Bedrock](https://bedrock.mxstbr.com/), a modern full-stack boilerplate with user authentication, subscription payments, teams, invitations, emails and everything else you need to build a SaaS product. We are excited that Max chooses Prisma as his ORM for this project! [Post on X](https://x.com/i/status/1372483017722187776) *** ## Community [#community] We wouldn't be where we are today without our amazing [community](https://www.prisma.io/community) of developers. Our [Slack](https://slack.prisma.io) has more than 40k members and is a great place to ask questions, share feedback and initiate discussions all around Prisma.
[Join Slack](https://slack.prisma.io) ### Meetups [#meetups] - [Prisma Meetup #3](https://www.meetup.com/Berlin-Prisma-Meetup/events/276603523/) - [GraphQL Berlin Meetup #20: Beginners Welcome! + quiz with prizes](https://www.meetup.com/graphql-berlin/events/275884588/) - [GraphQL Berlin Meetup #21 + win access to Advanced React course by Wes Bos!](https://www.meetup.com/graphql-berlin/events/276536880/) - [TypeScript Berlin #5 + win a Practical Functional Programming with TS workshop!](https://www.meetup.com/TypeScript-Berlin/events/276869417/) - [Advanced TypeScript Trickery - Open Mic Session #2](https://www.meetup.com/advanced-typescript-trickery/events/275863936/) ### Prisma Enterprise Event [#prisma-enterprise-event] The [Prisma Enterprise Event 2021](https://www.prisma.io/enterprise-event-2021) has been a huge success and we want to thank everyone who attended and helped making it a great experience! We've been excited to see fantastic speakers like [Pete Hunt](https://twitter.com/floydophone) (Twitter), [Natalie Vais](https://twitter.com/natalievais) (Amplify Partners), [James Governor](https://twitter.com/monkchips) (Redmonk) and [DeVaris Brown](https://twitter.com/devarispbrown) (Meroxa). The event covered a broad range of topics about the challenges large companies and enterprises face with the management of application data, such as: * Learn how top companies are addressing the challenges of data at scale * Discover how companies use Prisma to make their developers more productive * Get a better understanding of the future of data in the enterprise You can get access to all the talk recordings [here](https://prisma-data.typeform.com/to/YUln0miL).
- [Prisma Enterprise Event 2021](https://www.prisma.io/enterprise-event-2021)
[Watch Talks](https://prisma-data.typeform.com/to/YUln0miL) ## Stickers [#stickers] We love seeing laptops that are decorated with Prisma stickers, so we're shipping sticker packs for free to our community members! In this quarter, we've sent out over 300 sticker packs to developers that are excited about Prisma!
[Order Stickers](https://gist.github.com/nikolasburk/5b64014d41bc21594808cea82621df83) *** ## Videos, livestreams & more [#videos-livestreams--more] ### What's new in Prisma [#whats-new-in-prisma] Every other Thursday, [Nikolas Burk](https://twitter.com/nikolasburk) and [Ryan Chenkie](https://twitter.com/ryanchenkie) 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: [Watch the video on YouTube](https://www.youtube.com/watch?v=2CDHn-Maij0) * [2.19.0](https://www.youtube.com/watch?v=Ac-HWBTtLAU\&ab_channel=Prisma) * [2.18.0](https://www.youtube.com/watch?v=1Mul6jdmYvg\&list=PLn2e1F9Rfr6l1B9RP0A9NdX7i7QIWfBa7\&index=3\&t=1439s\&ab_channel=Prisma) * [2.17.0](https://www.youtube.com/watch?v=Iwhb33vm5uk\&list=PLn2e1F9Rfr6l1B9RP0A9NdX7i7QIWfBa7\&index=4\&t=1884s\&ab_channel=Prisma) * [2.16.0](https://www.youtube.com/watch?v=77PoedHJUM0\&list=PLn2e1F9Rfr6l1B9RP0A9NdX7i7QIWfBa7\&index=5\&t=1618s\&ab_channel=Prisma) * [2.15.0](https://www.youtube.com/watch?v=QH4Wyffsj-c\&list=PLn2e1F9Rfr6l1B9RP0A9NdX7i7QIWfBa7\&index=5\&t=1327s\&ab_channel=Prisma) * [2.14.0](https://www.youtube.com/watch?v=ATBdP-Yfaec\&list=PLn2e1F9Rfr6l1B9RP0A9NdX7i7QIWfBa7\&index=6\&t=1491s\&ab_channel=Prisma) ### Videos [#videos] #### Prisma Chats - All About Transactions with Matt Mueller, Product Manager at Prisma [#prisma-chats---all-about-transactions-with-matt-mueller-product-manager-at-prisma] [Watch the video on YouTube](https://www.youtube.com/watch?v=_8ex2PmdXPM) #### Prisma in Production: How to Load Test Your API with k6 (Daniel Norman) [#prisma-in-production-how-to-load-test-your-api-with-k6-daniel-norman] [Watch the video on YouTube](https://www.youtube.com/watch?v=ZV01hyVR1yw) #### Deploying a Prisma app to Vercel and setting up connection pooling with PgBouncer (Daniel Norman) [#deploying-a-prisma-app-to-vercel-and-setting-up-connection-pooling-with-pgbouncer-daniel-norman] [Watch the video on YouTube](https://www.youtube.com/watch?v=tsOHw2T1HvI) ### Prisma appearances [#prisma-appearances] This quarter, several Prisma folks have appeared on external channels and livestreams. Here's the overview of all of them: * [Ryan Chenkie @ WarsawJS Meetup #79 Online](https://www.youtube.com/watch?v=-5iz9g3-MmQ\&ab_channel=WarsawJS) * [Nikolas Burk @ Apollo livestream with Kurt Kemple](https://www.youtube.com/watch?v=I4IqM5dks2w\&t=2588s\&ab_channel=ApolloGraphQL) * [Mahmoud Abdelwahab @ ColbyFayock](https://www.youtube.com/watch?v=5UZBhWAlyTo\&ab_channel=ColbyFayock) * [Jason Kuhrt @ SFNode](https://www.youtube.com/watch?v=WUz5JulzSDA\&ab_channel=SFNode) * [Nikolas Burk @ Logrocket Podcast](https://podrocket.logrocket.com/8) *** ## New Prismates [#new-prismates] Here's an overview of the awesome new Prismates we have hired this quarter:
- **Vladi Stevanovic**, Sr. Customer Success Manager - **Chloé Votteler**, Organisational Psychologist - **Chris Matteson**, Head of Solutions Engineering - **Julieta Curdi**, Sr. Product Designer - **Rich Haines**, Tech Writer Also, **we are hiring** for various roles! If you're interested in joining us and becoming a Prismate, check out our [jobs page](https://www.prisma.io/company/careers).
[Explore Jobs](https://www.prisma.io/company/careers) ## What's next? [#whats-next] The best places to stay up-to-date about what we are currently working on are [GitHub issues](https://github.com/prisma/orm/issues) and our public [roadmap](https://pris.ly/roadmap). We are currently working on a [connector for MongoDB](https://www.notion.so/prismaio/Support-MongoDB-9f115ebf4a754069a7d7eaae94dc4651) and are hoping to have an Early Access version of it ready in the next three months. Another major area we are focusing on is the development of a *cloud product* that will make it easier for teams and larger organizations to collaborate on Prisma projects. To get an initial impression of what we are planning, you can [watch the talks from the Prisma Enterprise Event](https://prisma-data.typeform.com/to/YUln0miL). Stay tuned and keep an eye out for more articles on this blog in the next few weeks 👀