Prisma Versions Save

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

5.8.1

4 months ago

Today, we are issuing the 5.8.1 patch release.

Fix in Prisma Client

5.8.0

4 months ago

🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release. 🌟

Highlights

Happy New Year from your friends at Prisma! 🎊

In the last 4 weeks, we resolved some bugs on the ORM and made some progress on some exciting features that we’re not yet ready to announce. Stay tuned for the upcoming releases, in which we’ll be announcing new features. 😉

relationJoins improvements: Relation loading strategy per query (Preview)

In version 5.7.0, we released relationJoins into Preview. The relationJoins feature enables support for JOINs for relation queries.

This release adds support for the ability to specify the strategy used to fetch relational data per query when the Preview feature is enabled. This will enable you to choose the most efficient strategy for fetching relation data depending on your use case.

You can now load relation data using either of the following strategies:

  • join — uses JOINs to fetch relation data
  • query — uses separate queries to fetch relation data

When the relationJoins Preview feature is enabled, by default, the relation fetching strategy used is join. You can override the default behavior by using the relationLoadStrategy query option.

To get started, enable the Preview feature:

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["relationJoins"]
}

… and specify the relation loading strategy for your query as follows:

await prisma.user.findMany({
  relationLoadStrategy: 'query',
  include: {
    posts: true,
  },
})

Try it out and share your feedback and create a bug report if you encounter any issues.

Survey: Edge functions support

We’re working on bringing Edge function support to Prisma ORM and we would appreciate your input by submitting a response to our survey. By filling out the survey, you will be considered for our Early Access cohort as soon as we have something for you to try out.

Fixes and improvements

Prisma Client

Prisma Migrate

Language tools (e.g. VS Code)

Credits

Huge thanks to @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @tinola, @AikoRamalho, @luxaritas for helping!

Company news

🎉 A billion queries and counting: Prisma Accelerate

Prisma Accelerate, our global database cache has served over 1 billion queries since its General Availability launch.

We’d like to give a shoutout to our team and everyone who’s been with us on this journey. Stay tuned for some exciting products and features in the pipeline for 2024!

🔮 Prisma ORM Ecosystem

Are you building a cool tool, extension, generator, CLI tool or anything else, for Prisma ORM? Let us know.

We would like to learn about it and feature it on our Ecosystem page.

💼 We’re hiring

If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you. Check out our Careers page for open positions.

5.7.0

5 months ago

🌟 Help us spread the word about Prisma by starring the repo or posting on X (formerly Twitter) about the release.

Highlights

✨ In this release, we improved the SQL queries Prisma Client generates for you with two new Preview features, the driver adapters, and support for the database drivers we currently support. 5.7.0 will be the last release of the year. Stay tuned for the next one in January! ✨

Preview support for JOINs for relation queries for PostgreSQL and CockroachDB

We’re excited to announce Preview support for JOINs in Prisma Client when querying relations. Support for JOINs has been a long-standing feature request, and this release adds support for PostgreSQL and CockroachDB. The upcoming releases will expand support for other databases Prisma supports.

To get started using JOINs, enable the Preview feature in your Prisma schema:

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["relationJoins"]
}

Run prisma generate to regenerate Prisma Client and enable the Preview feature.

Prisma Client will use a JOIN in your query to fetch relation data for a majority of the cases.

Example queries

1-1 relation queries example

Prisma Client query

await prisma.user.findUnique({
	where: {
		id: 1
	},
	include: {
		profile: true
	}
})

SQL

SELECT
	"t1"."id",
	"t1"."name",
	"User_profile"."__prisma_data__" AS "profile"
FROM
	"public"."User" AS "t1"
	LEFT JOIN LATERAL (
		SELECT
			COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__"
		FROM
			(
				SELECT
					"t4"."__prisma_data__"
				FROM
					(
						SELECT
							JSON_BUILD_OBJECT(
								'id',
								"t3"."id",
								'bio',
								"t3"."bio",
								'userId',
								"t3"."userId"
							) AS "__prisma_data__"
						FROM
							(
								SELECT
									"t2".*
								FROM
									"public"."Profile" AS "t2"
								WHERE
									"t1"."id" = "t2"."userId"
							) AS "t3"
					) AS "t4"
			) AS "t5"
	) AS "User_profile" ON TRUE
WHERE "t1"."id" = $1
LIMIT $2
1-m relation queries example

Prisma Client query

await prisma.user.findUnique({
	where: {
		id: 1
	},
	include: {
		posts: true
	}
})

SQL

SELECT
	"t1"."id",
	"t1"."name",
	"User_posts"."__prisma_data__" AS "posts"
FROM
	"public"."User" AS "t1"
	LEFT JOIN LATERAL (
		SELECT
			COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__"
		FROM
			(
				SELECT
					"t4"."__prisma_data__"
				FROM
					(
						SELECT
							JSON_BUILD_OBJECT(
								'id',
								"t3"."id",
								'title',
								"t3"."title",
								'content',
								"t3"."content",
								'published',
								"t3"."published",
								'authorId',
								"t3"."authorId"
							) AS "__prisma_data__"
						FROM
							(
								SELECT
									"t2".*
								FROM
									"public"."Post" AS "t2"
								WHERE
									"t1"."id" = "t2"."authorId"
									/* root select */
							) AS "t3"
							/* inner select */
					) AS "t4"
					/* middle select */
			) AS "t5"
			/* outer select */
	) AS "User_posts" ON TRUE
WHERE "t1"."id" = $1
LIMIT $2
m-n relation queries example

Prisma Client query

await prisma.post.findUnique({
	where: {
		id: 1
	},
	include: {
		tags: true
	}
})

SQL

SELECT
	"t1"."id",
	"t1"."title",
	"t1"."content",
	"t1"."published",
	"t1"."authorId",
	"Post_tags_m2m"."__prisma_data__" AS "tags"
FROM
	"public"."Post" AS "t1"
	LEFT JOIN LATERAL (
		SELECT
			COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__"
		FROM
			(
				SELECT
					"Post_tags"."__prisma_data__"
				FROM
					"public"."_PostToTag" AS "t2"
					LEFT JOIN LATERAL (
						SELECT
							JSON_BUILD_OBJECT('id', "t4"."id", 'name', "t4"."name") AS "__prisma_data__",
							"t4"."id"
						FROM
							(
								SELECT
									"t3".*
								FROM
									"public"."Tag" AS "t3"
								WHERE
									"t2"."B" = "t3"."id"
									/* root select */
							) AS "t4"
					) AS "Post_tags" ON TRUE
				WHERE
					"t2"."A" = "t1"."id"
			) AS "Post_tags_m2m_1"
	) AS "Post_tags_m2m" ON TRUE
WHERE "t1"."id" = $1
LIMIT $2

Share your feedback and create a bug report if you encounter any issues.

Prisma’s distinct option now uses SQL queries (Preview)

From this release, Prisma Client’s distinct option now uses the native SQL DISTINCT ON for unordered queries with PostgreSQL and CockroachDB. The upcoming releases will expand support for the other databases that Prisma supports.

Prisma Client already supports querying for distinct records. However, Prisma Client took care of the post-processing for distinct records in memory.

To get started, enable the Preview feature in your Prisma schema:

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["nativeDistinct"]
}

Regenerate your Prisma Client to get started using the Preview feature.

Given the following Prisma Client query:

await prisma.user.findMany({
    distinct: ['role'],
    select: {
      role: true,
    },
})

Before 5.7.0

Previously, Prisma Client handled the post-processing to select distinct records in-memory. Therefore, the following query was generated and executed against your database:

SELECT
	"public"."User"."id",
	"public"."User"."role"::text
FROM
	"public"."User"
WHERE
	1 = 1 OFFSET $1

After 5.7.0

SELECT DISTINCT ON ("public"."User"."role")
	"public"."User"."id",
	"public"."User"."role"::text
FROM
	"public"."User"
WHERE
	1 = 1 OFFSET $1

Share your feedback and create a bug report if you encounter any issues.

Improved support for Netlify using Node.js v20

In this release, we improved Prisma support when deploying to Netlify on Node.js v20. Previously, the Prisma Client could not resolve the location of the Query Engine after deploying to Netlify when using Node.js v20. If you run into this issue, we recommend updating to Prisma v5.7.0.

We recommend giving this comment on GitHub a read if you are not yet able to upgrade Prisma, to learn how to get around the error.

Fixes and improvements

Prisma Client

Prisma

Prisma Migrate

Credits

Huge thanks to @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @christianledgard, @skyzh, @alula, @AikoRamalho, @petradonka for helping!

Company news

💼 We’re hiring!

If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.

We're hiring for the following roles:

5.6.0

6 months ago

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

🚀 Prisma Accelerate, our connection pool and global edge cache, is now Generally Available! Sign up to give it a try. 🚀

Highlights

Driver adapters improvements (Preview)

In version 5.4.0, we released driverAdapters into Preview. The driverAdapters feature enables Prisma Client to access your database using JavaScript or Serverless database drivers.

In this release, we fixed many bugs for the existing driver adapters. We appreciate all the community feedback that has helped us improve this feature!

PlanetScale serverless driver adapter improvements

This release also introduces a small breaking change to the @prisma/adapter-planetscale package to improve its stability and performance. The serverless driver adapter will now use a connection pool instead of a single connection from PlanetScale’s serverless driver.

In case you’re using the @prisma/adapter-planetscale, update your Prisma Client instance with the following:

-import { connect } from '@planetscale/database'
+import { Client } from '@planetscale/database'
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
import { PrismaClient } from '@prisma/client'
import { fetch as undiciFetch } from 'undici';

-const connection = connect({ url: connectionString, fetch: undiciFetch })
+const client = new Client({ url: connectionString, fetch: undiciFetch })

-const adapter = new PrismaPlanetScale(connection)
+const adapter = new PrismaPlanetScale(client)

const prisma = new PrismaClient({ adapter })

If you run into the following error: [TypeError]: PrismaPlanetScale must be initialized with an instance of Client., you can use the following snippet when defining your Prisma Client instance:

import { createRequire } from "node:module";
import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
import { fetch as undiciFetch } from 'undici';

const require = createRequire(import.meta.url);
const { Client } = require("@planetscale/database");

const client = new Client({ url:  process.env.DATABASE_URL , fetch: undiciFetch })
const adapter = new PrismaPlanetScale(client);

Request for feedback

We encourage you to try out the driver adapters and share your feedback to help us move it to General Availability in either of the following GitHub discussions:

Refer to our docs to learn more about driver adapters.

New prisma debug command

This release introduces a new command: prisma debug. The command provides debugging information such as environment variables that Prisma Client, Prisma Migrate, Prisma CLI, and Prisma Studio use. The command is also useful when creating a bug report as the information complements the output of the prisma -v command.

You can learn more about the command in our docs.

Read replicas extension improvements

We also released version 0.3.0 of the @prisma/extension-read-replicas package that contains the following improvements:

  • A new $replica() method that explicitly enables you to use a replica for your query.

    For example, by default, the queryRaw and executeRaw methods are forwarded to the primary database, as they could try to write to the database. You can use the $replica() method with either of the *Raw methods to explicitly execute your query against a replica instead of your primary database.

  • Validation for when there’s an empty list of replicas.

  • Webpack bundling fixes

We want to thank you, our community members, for your contributions! 🙏

You can find additional information on the changes in the extension’s release. You can learn more about the extension in the announcement blog post.

Package provenance

npm has introduced provenance statements to improve supply-chain security and transparency of packages. This allows developers to verify where and how packages are built.

Starting with the 5.6.0 release, all npm packages for Prisma ORM will be published with provenance statements. If you maintain a Prisma Client extension or generator, we encourage you to enable provenance statements when publishing to npm.

Fixes and improvements

Prisma Migrate

Prisma Client

Prisma CLI

Credits

Huge thanks to @onichandame, @LucianBuzzo, @RobertCraigie, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @christianledgard, @skyzh, @alula, @luxaritas, @Nasfame, @lukahartwig, @steebchen, @icanipa for helping!

Company news

Prisma Accelerate is now Generally Available

We're excited to share that Prisma Accelerate is now Generally Available. Prisma Accelerate is a global database cache that's available in over 280 locations and provides scalable connection pooling for serverless and edge applications.

Learn more in the announcement blog post. Sign up and try out Prisma Accelerate here.

💼 We’re hiring!

If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.

We're hiring for an Engineering Manager: Prisma Data Platform.

5.5.1

6 months ago

Today, we are issuing the 5.5.1 patch release.

Fix in Prisma Client

5.5.0

6 months ago

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

Highlights

Serverless database drivers improvements and request for feedback (Preview)

In version 5.4.0, we released driverAdapters into Preview. The driverAdapter feature enables Prisma Client to access your database using other JavaScript or Serverless database drivers such as Neon, PlanetScale, and Turso.

The driver adapters allow Prisma Client to connect to your database using protocols besides TCP, such as HTTP (PlanetScale and Turso) and WebSockets (Neon). You can learn more about the Preview feature from the announcement blog post.

In this release, we focused our efforts on fixing bugs and improving the stability of the Preview feature.

We encourage you to try it out and share your feedback to help us move it to General Availability in either of the following GitHub discussions:

New flags for the prisma init command

This release introduces 3 new flags you can provide when initializing Prisma in your project using the prisma init command:

  • --generator-provider: Defines the default generator to use
  • --preview-features: Specifies the default Preview features to use in your project
  • --output: Specifies the default output location for the generated client

Fixes and improvements

Prisma CLI

Prisma Client

Credits

Huge thanks to @onichandame, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @christianledgard, @skyzh, @alula, @michaelpoellath, @lukahartwig, @steebchen, @icanipa, @jiashengguo, @stephenwade for helping!

💼 We're hiring!

If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.

We're currently hiring for the following roles:

5.4.2

7 months ago

Today, we are issuing the 5.4.2 patch release.

Fix in Prisma Client

5.4.1

7 months ago

Today, we are issuing the 5.4.1 patch release.

Fix in Prisma Client

Fix in @prisma/adapter-planetscale