npm @prisma/client 2.8.0

latest releases: 5.21.0-dev.3, 5.21.0-integration-itx-refactor.16, 5.21.0-integration-itx-refactor.15...
4 years ago

Today, we are excited to share the 2.8.0 stable release 🎉

🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.

Major improvements

In today's release, we have two new features coming for you!

findFirst

While the findMany API gives you a powerful API to query your database with different 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 introduce 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"	
})

All filters available for findMany are also available in findFirst.

Case insensitive filters for PostgreSQL are now 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 Prisma Client generator any more:

generator client {
  provider        = "prisma-client-js"
- previewFeatures = ["insensitiveFilters"]
}

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: 'lowercase@UPPERCASE.com',
      mode: 'insensitive',
    },
  },
})

Note that this feature will not work if you're using database collations that do not know how to convert between upper- and lowercase letters (e.g. the C collation).

📚 Documentation: Case sensitivity / Case-sensitive filtering

Already existing preview features from previous releases

Just a quick reminder:

  • In version 2.6.0 we introduced one preview feature, namely atomicNumberOperations.
  • In version 2.1.0 we introduced two preview features, namely connectOrCreate and transactionApi.

In case they're useful for you, please give them a try and share your feedback! These features remain in preview in this release.

Fixes and improvements

prisma

prisma-client-js

language-tools

studio

prisma-engines

❓ 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!

Credits

Huge thanks to @nohns for some great contributions in this release!

Don't miss a new client release

NewReleases is sending notifications on new releases.