nikolasburk
schickling
06/03/2019, 4:08 PMnikolasburk
nikolasburk
nikolasburk
preview-1
, preview-2
, preview-3
, ... on Thursdays. You can find more info around the release process here: https://github.com/prisma/prisma2/tree/master/releases
Furthermore, we just shipped our first Preview release: preview-1
๐ ๐ข ๐
Next to a number of fixes and improvements that we tackled thanks to the issues you all opened, this preview comes with 3 major changes:
- Renamed project.prisma
to schema.prisma
- Renamed postgres
data source provider to postgresql
- Support for ZEIT Now deployments for Photon JS
You can find the detailled release notes here: https://github.com/prisma/prisma2/releases/tag/2.0.0-preview-1
Your help over the last two weeks was incredibly valuable! Please keep your questions, ideas and issues coming, that's the best way to help us accelerate the release process and ensure we're getting to a stable version of Prisma 2 as fast as possible! ๐Etel
jasonkuhrt
prisma/*
have migrated to prisma-labs/*
. Weโve setup #labs and our sprint work is public at https://github.com/orgs/prisma-labs/projects/1. The Labs team is eager to find transparent ways of working.
---
๐ฅ Second up is our announcement that starting with nexus-prisma@0.4
support for Prisma 1 will be dropped. For those following the repo youโve probably already sensed this coming, but we want to make this official and clear so that you can plan accordingly sooner than later. All current and future Prisma 1 specific GitHub issues have been/will be marked with a note/prisma1
label. You can expect these issues to generally not be worked on by the core team. In the future we will probably also close these issues as note/wontfix
to bring further clarity. Finally, expect a migration doc soon. We realize early adopters who invested heavily into nexus-prisma@0.3
may feel left out here. Please do chime in with any feedback you have in our tracking issue for this change at https://github.com/prisma/nexus-prisma/issues/378.
---
๐ฑ Thirdly is a state-of-nexus-prisma update. Over the next couple of weeks we will be rolling out various meta-infrastructure improvements to improve project velocity and health. Some of these include:
1. CI/CD releases so that you get value as soon as its ready (https://github.com/prisma/nexus-prisma/issues/379)
2. Rich changelog so that you can catch up on changes quickly and better use tools like renovate that will put this information right into your pull-requests (https://github.com/prisma/nexus-prisma/issues/407)
3. Giving you control over which version of nexus-prisma
your app depends on (no longer bundled inside Prisma 2 CLI) and using as a regular node library rather than a Prisma 2 generator (https://github.com/prisma/nexus-prisma/issues/395)
4. Revamping the docs and app examples (https://github.com/prisma/nexus-prisma/issues/380)
5. Revamping out issue labelling system (https://github.com/prisma-labs/issues/issues/1)
While perhaps not as exciting to you as product improvements, weโre optimistic for how this streamlined automation will facilitate team focus, and we think users will gain too with more transparency into our work and tighter feedback loops. As we iron out our processes, expect these patterns to be rolled out across more of Labsโ projects too.
We hope this underscores our commitment to nexus-prisma
and what may come in the future. Mapping your data layer to your API layer should be safe, easy, fun, and flexible. Itโs a key part of making data easy, Prismaโs mission. You should be able to focus on the design decisions and evolution of the mapping, while being mostly freed from its plumbing. You should at all times be able to summon a macro view of your mapping topology and generally be confident that the wiring from A-Z is bug free. And so a primary Q4 objective for the Labs team is reaching a 1.0 iteration on nexus-prisma. But of course the mapping space is a nuanced beast with a huge design surface. 1.0 will be but a start. Weโre excited to explore bold new ideas come 2020 sourced as much, we hope, from not just our own internal idea bank but the broader nexus and nexus-prisma
community. ๐๐ป ๐nikolasburk
Etel
nikolasburk
Note that Prisma Migrate and Prisma Studio areย notย part of today's release. They're both still considered experimental.Read theย announcement blog postย to learn everything you need to know about Prisma 2.0! ๐ย Getting started with Prismaย ๐ The easiest way to get started is by following theย Quickstartย (5 min). It is based on a SQLite demo database and doesn't require any setup! You can also connect Prisma to your own PostgreSQL or MySQL database, either inย anย existing projectย or whenย starting from scratch. ๐ฃ๏ธย Help us spread the wordย ๐ฃ๏ธ We're super excited about today's launch and would appreciate if you could help spread the word about Prisma! Share it with your friends and colleagues, we'd love to hear what everyone thinks of this new approach for working with databases. If you're on Twitter, it would mean a lot to us if you could share ourย announcement tweet!ย ๐ โฌ๏ธย Upgrading from Prisma 1ย โฌ๏ธ If you're currently using Prisma 1 and want to upgrade to the new version, you can start by learning about the upgrade process in the docs:ย How to upgradeย ๐ If you have any questions or feedback about the upgrade process, pleaseย create a GitHub issue in our new feedback repo. You can alsoย share your personal feedback pathย with us and we'll try to figure out the best way to upgrade with you! We're also planning upgrade webinars, where we're demoing the upgrade process for different scenarios (e.g. usingย
prisma-binding
, Prisma Client, Nexus, ...). The webinars are currently planned for July, we'll announce the dates soon!
โ๏ธย Let us know what you thinkย โ๏ธ
As always, we very much appreciate your feedback! Please don't hesitate to reach out on here on Slack or onย GitHubย if you have any questions, thoughts or any other kind of feedback about Prisma!ย ๐
๐ย Join us online for Prisma Day on June 25th and 26thย ๐
We're hosting another edition ofย Prisma Dayย this year and are going fully remote. Join us online for hands-on workshops on June 25th and great talks on June 26th. Some of the speakers include GitHub co-founderย Tom Preston-Werner, Netlify CEOย Mathias Biilmann Christensenย and lots of Prisma folks to tell you the latest about Prisma 2.0.
Sย A note on this Slackย S
We'll now make Prisma 2 theย defaultย for all Slack conversations. Concretely, this means:
โข we renamed the theย #prisma2-betaย channel to justย #prisma2
โข we created a dedicatedย #prisma1ย channel for conversations around Prisma 1Etel
nikolasburk
Json
ย data in Prisma Client
When querying data, you can now perform basic filtering withย Json
ย fields usingย equal
ย andย not
. Check out theย release notesย for an example.
๐ย Hide the Prisma CLI Update Message
You can now hide the Prisma CLI update notifier message by setting the environment variableย PRISMA_HIDE_UPDATE_MESSAGE
ย (e.g. toย "1"
,ย "true"
ย orย "asd"
).
โก*๏ธ Prepared statement caching for PostgreSQL*
Under the hood, we enabledย prepared statement cachingย for PostgreSQL. This way Prisma Client'sย query engineย does not repeatedly prepare the same statement but can reuse an existing one which reduces database CPU usage and query latency.
๐ย Many bug fixes for Prisma VSCode Extension
Theย Prisma VSCode extensionย received an extraordinary number of tiny fixes this release, which will make using it much more pleasant.
๐งช Experimental features
From this release onwards, we'll enableย experimentalย features that you can explicitly opt-in to! Note that these features are not part of your official and stable API and may be changed or removed completely in a future release.
Experimental features inย Prisma Clientย can be enabled via theย experimentalFeatures
ย field on theย generator
ย definition in your Prisma schema. In this release, two new experimental features are released:
โขย `connectOrCreate`: A new query option similar toย upsertย but used inside ofย nested writesย (issue)
โขย `transactionApi`: Enables a newย transaction
ย function in Prisma Client that lets you execute multiple write operations wrapped in a transaction (issue)
Here is how you can enable them for your Prisma Client:
generator client {
provider = "prisma-client-js"
experimentalFeatures = ["connectOrCreate", "transactionApi"]
}
Be sure to runย npx prisma generate
ย after you've added these fields to update your generated Prisma Client.
To enable experimental features in theย Prisma CLI, you need to add explicitย experimental flagsย when running a command. This Prisma release contains an experimental feature for theย prisma introspect
ย command that keeps your manual changes in the Prisma schema after youย re-introspectย your database (e.g.ย @map
ย andย @@map
ย attributes and relation field names). If you want to try out this functionality, you need to add theย --experimental-reintrospection
ย flag to theย prisma introspect
ย command:
npx prisma introspect
You can learn more about all features in theย release notes, we're looking forward to your feedback for the new version!ย ๐ย ๐Etel
nikolasburk
datasource
provider dynamic via environment variables
The provider
field on the datasource
definition in your Prisma schema now also accepts an array of strings (instead of just a plain string). This can be helpful when you want to switch environments which point to different databases based on an environment variable. Learn more about this feature
https://github.com/prisma/prisma/issues/1487.
๐งช Experimental features
After adding connectOrCreate
and transactionApi
as the first experimental features in the last release, we're now excited to release another feature to the experimental stage: Aggregation queries with Prisma Client. In addition to the already existing count
query, you can now let Prisma Client calculate sum, minimum, maximum and average values for any fields of type Int
or Float
in your Prisma schema!
You can learn more about all features in the release notes, we're looking forward to your feedback for the new version! ๐ ๐tim2
07/21/2020, 3:48 PMprisma introspect
until recently ordered all fields in models alphabetically. Starting with 2.3.0 it now picks up the order from the columns in your database table and uses that same order for the fields in your models in your Prisma Schema file.
prisma cool Experimental features have been renamed to preview features
With 2.1.0
we introduced feature flags for Prisma Client, called โExperimental Featuresโ. The property in the schema has been renamed from experimentalFeatures
to previewFeatures
to better communicate what they actually are.
๐ฆ Distinct API (preview)
We introduce distinct querying capabilities to Prisma Client.
It allows you to query for distinct (unique) rows of a model.
const result = await prisma.user.findMany({
where: {},
distinct: ['name']
})
๐ Middlewares API (preview)
Inspired by Koa - Prisma Client now allows you to provide powerful async middlewares.
prisma.use(async (params, next) => {
console.log('params', params)
const before = Date.now()
const result = await next(params)
const after = Date.now()
console.log(`Query ${params.model}.${params.action} took ${after - before}ms`)
return result
})
You can learn more about all features and fixes in theย release notes, weโre looking forward to your feedback for the new version!nikolasburk
orderBy
ย object can now have as many fields as you want! The order of the fields hereby determines the order of the returned list (see example below).
You can use it like so:
// order by `age` descending and then by `name` ascending
const users = await prisma.user.findMany({
orderBy: {
age: 'desc',
name: 'asc'
}
})
As mentioned by the comment, the returned objects inย users
ย are orderedย firstย byย age
ย (descending), andย thenย byย name
ย (ascending).
๐ฐย Introducedย $
ย dollar prefix for top-level Prisma Client methods
In recent versions, we introduced a couple of top-level methods in Prisma Client (e.g.ย prisma.transaction()
ย andย prisma.use()
) inย previewย mode. The immediate feedback was that the denylist for model names grew - whichย breaks Prisma schemasย where a model is calledย Transaction
,ย transaction
,ย use
, orย Use
. And the list goes on...
In order to have a future-proof API, that allows maximum expressibility in terms of model names, we decided to prefix all non-query methods with a dollar signย $
. That means Prisma Client will from now on ship with the following methods:
Pre-existing:
-ย $disconnect
-ย $connect
-ย $on
-ย $queryRaw
-ย $executeRaw
Still in preview:
-ย $use
-ย $transaction
The preview methods have already been renamed, the pre-existing methods likeย connect
ย are still available, you just get a deprecation warning. They will be available for a few more releases with an alias, so no hurry to update them yet.
๐ฅ๏ธย Updates in Prisma Studio
With this release, we shipped a number of improvements and changes for Prisma Studio:
โข Refreshed design
โข Moved theย Reloadย button from the right of the databrowser to the left
โข Moved theย Pending Actionsย bar from the bottom of the databrowser to the top right
โข Removed the sidebar; to open a model, you can now press theย New Tabย button on the top
โข Removed the code editor
โข Removed the tree view
โข Added ability to view and edit JSON fields
Try out Prisma Studio in theย online demoย or in your Prisma project by running:
npx prisma studio --experimental
๐ย Preview features
Just a quick reminder that we currently have the following preview features:
โขย connectOrCreate
โขย transactionApi
โขย aggregateApi
โขย distinct
โขย middlewares
In case they're useful for you, please give them a try andย share your feedback! These features remain in preview in this release.
๐ย 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 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.Alberto Perdomo
nikolasburk
middlewares
(for intercepting Prisma Client queries | ๐ docs)
- distinct
(to remove duplicates from findMany
| ๐ docs)
- aggregationsApi
(to calculate aggregate values of number type columns | ๐ docs)
If you've used these features in prior releases, you can remove the respective feature flag from the generator
block in your Prisma schema after upgrading to 2.5.0
.
๐ New preview feature: Case insensitive filters for PostgreSQL
In 2.5.0
, we introduce case insensitive filters to Prisma Client. It allows you to query for fields of type String
in a case insensitive way.
The new mode
option you can pass to findMany
queries influences the corresponding filter (e.g. equals
, contains
or startsWith
) but doesn't change the return type of the findMany
query. mode
can have two possible values:
โข `default`: Uses the default filter configured on the database level. If the collation is configured as case insensitive in the database, the default mode will be case insensitive as well. In that case, there's no need to use the insensitive mode.
โข `insensitive`: Uses the case insensitive filter (if possible).
Here is an example of using mode
with `equals`:
const result = await prisma.user.findMany({
where: {
email: {
equals: '<mailto:lowercase@UPPERCASE.com|lowercase@UPPERCASE.com>',
mode: 'insensitive',
},
},
})
๐ย 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 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.
โ๏ธ Share your experience with Prisma on Reddit
There currently is an interesting discussion on Reddit about Which ORM should I use? (TypeScript). If you already have some experience with Prisma, we'd love if you could take a few minutes and write up your honest thoughts and experience about using Prisma in a project so far. This helps other developers better understand how Prisma fits in and what benefit they might get from it as well as where its current limitations might be! ๐nikolasburk
prisma introspect
ย (e.g. any usage ofย @map
ย andย @@map
ย or the renaming of relation fields).
Keeping these manual changes in the Prisma schema file has been available as a preview feature via theย --experimental-reintrospection
ย option already. After getting tested as a preview feature for a few releases, we are excited to promote this functionality to be the default behavior ofย prisma introspect
ย into this stable release.
๐ขย Atomic number operationsย (preview)
With today's release, we introduce atomic number operations forย update
ย queries in Prisma Client. It allows you to update the values of certain number fieldsย atomicallyย (i.e. as a single Prisma Client query).
The new operations work withย Int
ย andย Float
ย type fields:
โขย `increment: x`: Addsย x
ย to the current value
โขย `decrement: x`: Subtractsย x
ย from the current value
โขย `multiply: x`: Multiplies the current value byย x
โขย `divide: x`: Divides the current value byย x
โขย `set: x`: Sets the value toย x
Here's an example of using theย increment
ย operation:
const result = await prisma.user.update({
where: {
email: '<mailto:alice@prisma.io|alice@prisma.io>',
},
data: {
age: {
increment: 1, // age = age + 1 - Happy Birthday!
}
},
})
๐ย 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 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.
๐คย How would you describe Prisma?
We'd love to hear from you how you describe Prisma to your developer friends and coworkers. If you have 2 minutes, please answer this question via thisย online form.nikolasburk
prisma studio
command without the previously required --experimental
flag:
npx prisma studio
โ๏ธ Configure Prisma schema location via package.json
for more flexibility
Previously, your schema.prisma
file needed to be available at a specific location when running Prisma CLI commands or provided via the --schema
option when invoking a Prisma CLI command.
With this release, you can configure the location of your Prisma schema via a prisma
property in your `package.json`:
{
"prisma": {
"schema": "path/to/schema.prisma"
}
}
The provided location in package.json
will be the default location of the Prisma schema file for any Prisma CLI command you invoke. Note that you can still override this default location by manually specifying the --schema
option when invoking a Prisma CLI command.
๐ย Learn more in the release notes
For more info and links to documentation, you can read theย release notes.
๐ Feedback wanted: How does introspection work for you?
In the last few releases, we improved Prisma's database introspection with bigger and smaller improvements. We think it is pretty stable now, and would love to hear from you how you have been using prisma introspect
recently!
If you have used introspection in the past, whether it worked well or not so well with your database, please let us know by sharing your feedback on GitHub!
๐ย Help us spread the word about Prismaย ๐
To help spread the word about Prisma, we'd very much appreciate 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.nikolasburk
findFirst
ย to query a single item with the same filters fromย findMany
While theย findMany
ย API gives you a powerful API to query your database with variousย filters, it's not ideal if you just want to queryย a single item. On the other hand, theย findOne
ย API returns single items, but it only allows for filtering byย uniqueย fields.
In versionย 2.8.0
, we're introducingย findFirst
ย - giving you the full power ofย findMany
ย filters while only returning the first item that matches the filter criteria.
So instead of this:
const usersCalledAlice = await prisma.user.findMany({
name: "Alice"
})
const firstUserCalledAlice = usersCalledAlice[0]
You can now do this:
const firstUserCalledAlice = await prisma.user.findFirst({
name: "Alice"
})
๐ย Case insensitive filters for PostgreSQL promoted to stable
Inย 2.5.0
ย we introduced case insensitive filters for PostgreSQL, in today's release we're promoting this feature to stable. This means you don't need to include theย insensitiveFilters
ย feature flag in theย previewFeatures
ย field of the Prisma Client generator any more.
The newย mode
ย option you can pass toย findMany
ย influences the corresponding filter (e.g.ย contains
ย orย startsWith
) but doesn't change the return type of theย findMany
ย query.ย mode
ย can have two possible values:
โขย `default`: Uses the default filter configured on the database level. If the collation is configured as case insensitive in the database, the default mode will be case insensitive as well. In that case, there's no need to use theย insensitive
ย mode.
โขย `insensitive`: Uses the case insensitive filter (if possible).
const result = await prisma.user.findMany({
where: {
email: {
equals: '<mailto:lowercase@UPPERCASE.com|lowercase@UPPERCASE.com>',
mode: 'insensitive',
},
},
})
You can learn more about this feature in theย docs.
โย Are you using Prisma at work?
We'd love to know if you're using Prisma at work. Answer with a quickย yesย orย noย in ourย poll, it won't take longer than a few seconds!
๐ย 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 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.Daniel Norman
clientVersion
field which contains the version of Prisma Client. This is useful for debugging and creating issues.
โณ๏ธ Improved error message of prisma.$transaction
When you use prisma.$transaction
to group multiple calls into a single transaction, you need to pass an array of promises. Passing calls that have been awaited will now trigger a more helpful error:
Error: All elements of the array need to be Prisma Client promises. Hint: Please make sure you are not awaiting the Prisma client calls you intended to pass in the $transaction function.
๐ย 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 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.
๐ฎ Interested in providing feedback for the upcoming version of Prisma Migrate?
We are seeking users interested in trying out upcoming versions of Prisma Migrate. This will involve trying it out, validating functionality, and sharing feedback with us.
If youโre interested in participating, fill out the following form, it wonโt take longer than a minute!
๐ Join us for the first Prisma Online Meetup on October 28, 2020 6pm CET
Join with engineers from all around the globe for the to learn about database best practices, the Prisma inside scoop, and examples of Prisma in production on October 28 at 6pm CET.
Featured in this Meetup:
โข Tammy Bryant, Principal SRE of Gremlin: โDatabase horror storiesโ.
โข Herve Labas, Prismaโs VP of Product, talking about the future of Prisma and its roadmap.
โข Success story of an app built with Prisma told by its creator.
The event will be streamed on , be sure to set a reminder.nikolasburk
sqlserver
ย connector. Note that while it's inย Preview, you also need to add the additionalย previewFeature
ย flagย microsoftSqlServer
ย in the generator for Prisma Client:
datasource db {
provider = "sqlserver"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["microsoftSqlServer"]
}
Learn more in theย documentationย or read theย announcement blog post!ย ๐
๐ฒ๏ธย Single-command schema changes for prototyping (Preview)
With this release, we are introducing a new command that lets youย pushย the state of your Prisma schema file to the database without using migrations:ย prisma db push --preview-feature
The idea behindย prisma db push
ย is that you only care about theย end stateย of your database schema, but not aboutย howย this end state is achieved.
Also note that the command runsย prisma generate
ย for you, so you're saving an extra step after having updated your Prisma schema!ย ๐
Learn more in theย documentation!ย ๐
๐ย 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 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.
๐ฎย Interested in providing feedback for the upcoming version of Prisma Migrate?
We are seeking users interested in trying out upcoming versions of Prisma Migrate. This will involve trying it out, validating functionality, and sharing feedback with us.
If youโre interested in participating,ย fill out the following form, it wonโt take longer than a minute!
๐ย Join usย todayย for the first Prisma Online Meetup on October 28, 2020 6pm CET
Join with engineers from all around the globe for theย ย to learn about database best practices, the Prisma inside scoop, and examples of Prisma in productionย in less than an hourย (October 28)ย at 6pm CET | 10am PDT.
โข Tammy Bryant, Principal SRE of Gremlin: โDatabase horror storiesโ.
โข Herve Labas, Prismaโs VP of Product, talking about the future of Prisma and its roadmap.
โข Success story of an app built with Prisma told by its creator.
๐ฐ Join our What's new in Prisma livestream tomorrow
Catch @ryan and me tomorrow on as we are are discussing the latest news from the Prisma ecosystem and community in the next __ livestream! ๐
The event will be streamed onย ย ๐บnikolasburk
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeTypes"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
name String? @db.VarChar(255)
}
model Post {
id Int @id @default(autoincrement())
title String @db.VarChar(100)
createdAt DateTime @db.Timestamp(6)
wordCount Int @db.SmallInt
}
You can enable native types in your Prisma schema using theย nativeTypes
ย feature flag.
๐ย New scalar types in the Prisma schema:ย BigInt
,ย Bytes
ย andย Decimal
ย (Preview)
We're also adding new scalar types to the Prisma schema! From today on, you can useย ย BigInt
,ย Bytes
ย andย Decimal
. Check out theย release notesย to see how these are mapped to your database and to JavaScript/TypeScript when querying with Prisma Client JS.
You can enable those with theย nativeTypes
ย feature flag in your Prisma schema as well.
๐ธย Set foreign keys directly (Preview)
This new Preview feature has been long requested and we're excited to make it finally happen. It'll make your code less verbose when you're working with relations. You now don't need to use a nested write withย connect
ย orย disconnect
ย any more to "rewire" a relation of two records, but instead you can just "set the foreign key" directly:
await prisma.post.create({
data: {
// You can now set the foreign key directly...
authorId: 1,
// ... or connect the relationship...
// author: {
// connect: {
// id: 1
// }
// }
// ... but not both at the same time
},
});
You can enable those with theย uncheckedScalarInputs
ย feature flag in your Prisma schema as well.
๐พย More exiting features
Thanks to your feedback, we were able to promote theย $transaction
ย andย connectOrCreate
ย APIs from Preview to this stable release!ย ๐ย This means you don't need to include the respective feature flag in your Prisma schema any more to use them. If you're curious about the remaining improvements in this release, be sure to check out theย release notes.
๐คฉย Prisma Migrate is in Early Access
We're making great progress with Prisma Migrate and were able to open up an Early Access program. You can learn everything you need to know in order to try out Prisma Migrateย here. If you're just curious about the new workflows, check out this quickย ย recorded from our VP of Productย @Hervรฉ - Product at Prisma. Share your thoughts about the new version of Prisma Migrate in the #product-feedback channel ๐
๐ย Help us spread the word about Prismaย ๐
To help spread the word about Prisma, weโd very much appreciate 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 our What's new in Prisma livestream on Thursday
Catch @ryan and me on Youtube as we are are discussing the latest news from the Prisma ecosystem and community in the next!ย ๐
๐ย Make your online talk recordings more accessible with subtitles
We'd love to help you make your talk recordings (no matter if Meetup or conference talk) more accessible byย adding subtitlesย to itย for free! Reach out toย sponsorships@prisma.ioย if you are interested in getting subtitles for your videos!nikolasburk
.dmg
ย from theย Studio release page.
Support for more platforms (Windows and Linux) will follow soon!
๐ฆฟย Prisma codemods help upgrading your codebase
With today's release, we took the opportunity to cleanup some rough edges in the Prisma Client API which partially results in breaking changes. To help you with upgrading your codebase to 2.12.0,ย we're introducingย `@prisma/codemods`.
Theย @prisma/codemods
ย package provides a powerful CLI that scans your codebase and automatically updates the code to the new API calls from the provided version.
The upgrade workflow looks like this:
cd my-app
npm install @prisma/cli --save-dev
npm install @prisma/client
npx @prisma/codemods update-2.12 ./
๐คย Microsoft SQL Server now supports native database types (Preview)
Hot off the presses: You can now use native database types with Microsoft SQL Server by specifying both theย microsoftSqlServer
ย andย nativeTypes
ย feature flags in your Prisma schema:
generator js {
provider = "prisma-client-js"
previewFeatures = ["microsoftSqlServer", "nativeTypes"]
}
datasource ms {
provider = "sqlserver"
url = env("DATABASE_URL")
}
model User {
id BigInt @id @default(autoincrement()) @ms.BigInt
name String? @ms.VarChar(255)
}
โ ๏ธย Breaking changes and deprecations
The cleanup in this release comes with a number of breaking changes:
โข Removal of deprecated non-$
ย methods: Some top-level Prisma Client methods have been prefixed with aย $
ย a few releases ago. While the non-$
ย versions of these methods still continued to work, we're finally removing them in this release, meaning you now need to make sure you're adfding theย $
ย (e.g. for calls likeย prisma.$transaction()
,ย prisma.$connect()
ย orย prisma.$disconnect()
).
โข 1-1-relations must now have an optional side: The Prisma schema used to allow 1-1-relations that were required on both sides. This is not allowed any more as of this release. The fastest way to update your existing 1-1-relations to this new requirement is by runningย npx prisma introspect
.
โข Fix how data forย Json[]
ย fields is stored: The way how fields of typeย Json[]
ย have been stored in previous releases had a number of issues. This release fixes these issues: Previously, JSON arrays were stored as a string inside a your database'sย JSON
ย column. Now, they are properly encoded JSON arrays in the database.
The following changes are not yet breaking, but indicate a future breaking change via deprecation:
โขย findOne
ย is renamed toย findUnique
ย to give more clarity about the behaviour of the method
โข Exported types fromย @prisma/client
ย are now under aย Prisma
ย namespace
Learn all about the breaking changes in theย release notes.
๐คฉย Upcoming Prisma Migrate Preview Release
Weโve got a Preview release of Prisma Migrate nearing up with a large set of changes. You can test it in Early Access, see the upcoming changes, and provide feedback! Get started with the Early Access versionย here.
Share your feedback and questions in the #product-feedback channel!
๐ย Help us spread the word about Prismaย ๐
To help spread the word about Prisma, weโd very much appreciate 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 our What's new in Prisma livestream on Thursday
Catch @ryan and me on Youtube as we are are discussing the latest news from the Prisma ecosystem and community in the nextย !ย ๐nikolasburk
nikolasburk
groupBy
ย flag to theย generator
ย block in your Prisma schema. Here is an example for invoking the newย groupBy
ย query:
const locations = await client.agent.groupBy({
by: ['location'],
min: {
rate: true
},
})
// Result:
// [
// { location: "Los Angeles", min: { rate: 10.00 } },
// { location: "London", min: { rate: 20.00 } },
// { location: "Tokyo", min: { rate: 30.00 } }
// ]
Note that Prisma also supports theย having
ย side of group by, so you can further filter your groups. You can read more about the group by queries in theย documentation.
๐ย Linux ARM64 support
Good news for Linux users! Prisma now supports Linux ARM64 out of the box. If you already generate the Prisma Client on a Linux ARM box, it will just work. To target the specific binary, you can add aย binaryTarget
ย to theย generator
ย block in your Prisma schema:
generator client {
provider = "prisma-client-js"
binaryTargets = ["linux-arm-openssl-1.1.x"]
}
Learn more in theย documentation.
๐บ๏ธย Prisma Migrate fix for PostGIS users
PostgreSQL users who are using the PostGIS extensionย can now use Prisma Migrateย as well.
๐ย 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 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 on Thursday for the "What's new in Prisma" livestream
As usual, my colleague @ryan and I will discuss the latest release and other news from the Prisma ecosystem in aย ย onย Thursday at 5pm Berlin | 8am San Francisco.nikolasburk
select
When usingย count
ย queries, you can provide a number of options, e.g. for filtering. This release introduces theย select
ย option forย count
ย queries which lets you filter for non-null values ofย multipleย fields in a single query.
Check out the release notes for moreย infoย and examples.
โ
ย Modifying relations by directly setting foreign keys is now stable
In 2.11.0, we introduced theย uncheckedScalarInputs
ย preview flag which allowed you to modify relations by directly setting foreign keys in your queries (as opposed to using a nested write with theย connect
ย option). Fire up that delete key because you can now remove this flag from your Prisma schema!
Read more about in theย documentation on relation queries.
๐ย Dark mode for Prisma Studio & more powerful filtering
As of this release, Prisma Studio can be used in dark mode! You can use theย Settingsย icon in the top right corner to switch between light and dark mode.
We also included more powerful ways for you to filter the records of a table:
โข Filter byย Json
ย fields
โข Filter by the ID of a related model
๐ฏย More improvements for Prisma Migrate
โข Prisma Migrate now detects when the migrations donโt match the configuredย provider
ย on yourย datasource
ย block, for example when the migrations have been created withย sqlite
ย but theย provider
ย is now set toย postgresql
. Prisma Migrate will now print a helpful error message in these cases.
โขย prisma migrate reset
ย can now be used in non-interactive environments (e.g. CI/CD) by passing theย --force
ย flag.
โข The new seeding functionality (see above) will be automatically triggered wheneverย prisma migrate reset
ย is called to reset and repopulate the database in development. It's also triggered when the database is reset interactively after callingย prisma migrate dev
.
๐ฆฆย Transaction API for Prisma Client Go
Prisma Client Go now supports database transactions with a sparkly newย Transaction
ย API:
go
createA := client.User.CreateOne(
db.User.ID.Set("c"),
db.User.Email.Set("a"),
)
createB := 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
}
Learn more aboutย Transaction
ย in theย reference. If you'd like to try out Prisma Client Go, check out theย Quickstartย for a gentle introduction and share your feedback in the #prisma-client-go channel.
๐ย 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 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 on Thursday for the "What's new in Prisma" livestream
As usual, my colleague @ryan and I will discuss the latest release and other news from the Prisma ecosystem in aย livestream onย ย onย Thursday at 5pm Berlin | 8am San Francisco.nikolasburk
prisma db seed
ย command which is introduced in Preview in this release. Seeding is currently supported via scripts written in TypeScript, JavaScript, Go and Shell.
The command expects a file calledย seed
ย with the respective file extension inside your mainย prisma
ย directory.
Check out theย release notesย for more info. Please provide feedback for the newย prisma db seed
ย commandย here.
๐ฅย Throw exceptions inย findFirst
ย andย findUnique
ย queries if no record is found
With the newย rejectOnNotFound
ย option, you can now tell Prisma Client to throw an exception whenย findFirst
ย orย findUnique
ย does not find any records.
Here's an example:
const user = await client.user.findUnique({
where: {
id: 10,
},
rejectOnNotFound: true
})
// Throws "NotFoundError: No User found" if the
// user with id = 10 does not exist.
If you omitย rejectOnNotFound
, these calls continue to returnย undefined
.
๐ย Improved API for filtering arrays in PostgreSQL
We've added some new capabilities to yourย where
ย condition for filtering arrays in PostgreSQL:
โขย `has`: a value is contained within the array
โขย `hasEvery`: all values are contained within the array
โขย `hasSome`: at least one values is contained in the array
โขย `isEmpty`: the array is empty
Here's an example:
const admin = await prisma.user.findFirst({
where: {
id: 1,
roles: {
has: 'ADMIN'
}
}
})
nikolasburk