Prisma: 2.2.0 Release

Release date:
July 7, 2020
Previous version:
2.1.3 (released June 25, 2020)
Magnitude:
3,651 Diff Delta
Contributors:
6 total committers
Data confidence:
Commits:

64 Commits in this Release

Ordered by the degree to which they evolved the repo in this version.

Authored June 30, 2020
Authored July 1, 2020
Authored July 3, 2020
Authored July 3, 2020
Authored July 2, 2020
Authored June 29, 2020
Authored July 6, 2020
Authored July 6, 2020
Authored July 3, 2020
Authored July 6, 2020
Authored June 30, 2020
Authored July 1, 2020
Authored July 3, 2020
Authored July 2, 2020
Authored July 5, 2020
Authored July 2, 2020
Authored July 7, 2020
Authored July 2, 2020
Authored July 7, 2020

Top Contributors in 2.2.0

timsuchanek
Jolg42
AryanJ-NYC
janpio
renovate-bot
prisma-bot

Directory Browser for 2.2.0

We haven't yet finished calculating and confirming the files and directories changed in this release. Please check back soon.

Release Notes Published

Today, we are issuing the 2.2.0 stable release.

Major improvements

Next to a lot of bug fixes, this version includes a number of new features!

Quick fix suggestions in Prisma VSCode Extension

The Prisma VS Code extension now helps you fix any accidental typos and offers more convenient "Quick Fixes" right inside your editor.

<img src="https://imgur.com/SmgDmZM.gif" width="500px" />

Make datasource provider dynamic via environment variables

The provider field on the datasource defininitions 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 here.

datasource db {
  provider = ["sqlite", "postgres"]
  url      = env("DATABASE_URL")
}

Experimental features

Already existing experimental features

Just a quick reminder: In v2.1.0 we introduced two experimental features, namely connectOrCreate and transactionApi. In case they're useful for you, please give them a try! They stay experimental in this release.

Re-Introspection

We were able to continue to improve the re-introspection flow based on your feedback. Thanks!

Aggregations API

While Prisma Client already provides a count query for each model, we now introduce further aggregation functionality for number fields.

If your model has a field of type Int or Float, the following aggregations will be available:

  • sum: Sum up all values of a field for the selected rows.
  • min: Get the minimum value for a field for the selected rows.
  • max: Get the maximum value for a field for the selected rows.
  • avg: Get the average value for a field for the selected rows.

Example

Note, that the count API is always available, while sum, min, max, and avg are only available for a model if it has a number field.

<table> <thead> <tr> <th>Prisma Schema</th> <th>Prisma Client Query</th> <th><pre>Result</pre></th> </tr> </thead> <tbody> <tr> <td> <pre lang="prisma"> model User { id Int @id age Int name String } </pre> </td> <td> <pre lang="js"> const result = await prisma.user.aggregate({ where: { age: { gt: 5 } }, // optional count: true, avg: { age: true, }, max: { age: true, }, min: { age: true, }, sum: { age: true } }) </pre> </td> <td>

<pre lang="js"> { "count": 10, "avg": { "age": 80 }, "max": { "age": 163 }, "min": { "age": 5 }, "sum": { "age": 800 } } </pre>

</td> </tr> </tbody> </table>

Feature flag

In order to enable this experimental feature, note that you need to set the feature flag aggregateApi in the Prisma Client generator block in your schema:

generator client {
  provider = "prisma-client-js"
  experimentalFeatures = ["aggregateApi"]
}

Please share your feedback on how this feature works for you. We are interested in both positive and negative feedback, so we know if this feature is already ready for production! (If encounter any problems, please open a new issue here).

Fixes and improvements

prisma

prisma-client-js

migrate

vscode

studio

prisma-engines