Today, we are issuing the 2.4.0
stable release.
🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release 🌟
Major improvements
Order by multiple fields
A long-awaited feature - the ability to order by multiple fields in Prisma Client is finally here!
Until now you could only order by a single scalar field of a model. The API design however was already prepared for ordering multiple fields with the object syntax we have. Instead of just one property, that 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).
Note: As this is an incremental change in the API, we introduce this feature without a feature flag.
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).
📚 Documentation: Sort on multiple fields
Top-level Client Methods: $
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 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
Changes to middlewares
and transactionApi
As mentioned above, we ar changing the names of some the top-level Prisma Client methods. This affects the two preview features middlewares
and transactionApi
.
middlewares
You still need to enable the preview feature via the generator
block in your Prisma schema to access it:
generator client {
provider = "prisma-client-js"
previewFeatures = ["middlewares"]
}
Before
prisma.on()
After
prisma.$on()
transactionApi
You still need to enable the preview feature via the generator
block in your Prisma schema to access it:
generator client {
provider = "prisma-client-js"
previewFeatures = ["transactionApi"]
}
Before
prisma.transaction()
After
prisma.$transaction()
Already existing preview features from 2.1.0
, 2.2.0
, and 2.3.0
Just a quick reminder:
- In version
2.1.0
we introduced two experimental features, namelyconnectOrCreate
andtransactionApi
. - In
2.2.0
we introducedaggregateApi
. - In
2.3.0
we introducedmiddlewares
and thedistinctApi
.
In case they're useful for you, please give them a try and share your feedback! These features remain in preview in this release.
🌟 Help us spread the word about Prisma
To help spread the word about Prisma, we'd very much appreciate if you would star this repo 🌟 And if you're excited about the features in this week's release, then help us and share it on Twitter.
Fixes and improvements
prisma
- [Introspection] Do not print
@default("")
for String fields - Prisma introspect: extra field for self-relations
- Prisma 1 CLI (for versions smaller than 1.34) and Prisma 2.0 CLI share the same command
- Clarify schema comments
CreateInput
andUpdateInput
have different typings for optional relations- Loss of precision on Float fields
- pgbouncer=true flag not working as expected with a relation and enums on both sides of the relations
- Relation + enums + pgbouncer fails with a ConnectorError
- Implicit m-n relations have an extra
@relation
field after introspection - Supported feature combination coverage (MySQL + SQLite)
- Support setting a timeout for SQLite
- CLI won't run in AWS Lambda
- Prisma Client is generated twice when
output
is specified ongenerator
- [Re-Introspection]
@@map
and@map
with argumentname
loses thename
after re-introspection - Surface schema validation errors during Re-Introspection and change flow
- Validate uniqueness of names of indexes on databases which doesn't allow two indexes with the same name
- [Re-Introspection] Enum with
@map
will get option commented if it invalid without map - optional one-to-many relationship: none/every filters: Incorrect SQL generated
- Problems with middleware for tracing
- Self-referential one-to-one relationship. Incorrect SQL for
{ where: { non_fk_field: null } }
prisma-client-js
- Ability to sort results by multiple attributes
- Upsert should allow where clause with only undefined
- AWS Lambda: Unknown error in Prisma Client
migrate
language-tools
- Add support for /* Prisma */ syntax highlighting
- Extension only release automation
- Publish Insider extension on every commit
- Extension only sub-patch release process
- A patch release for CLI should be based on a tag and not master
- Dev instructions for working with language server are outdated.
- Streamline debugging of language server before published to npm
- Implement workaround for hanging types in LSP
- Run e2e tests before publishing on mac, windows as well
- Blank lines removed in model one by one in VS Code
- Syntax highlighting broken when using map attribute inside enum
- Formatting does not add missing relation automatically
- Show previewFeatures in generator block as auto-completion suggestion
- @unique only gets suggested once per model block
- Recognize usage of experimentalFeatures and give warning and quick-fix
- Using F2 on relation field leads to broken schema
- Snapshot tests for change-readme script