diff --git a/content/100-getting-started/01-quickstart-prismaPostgres.mdx b/content/100-getting-started/01-quickstart-prismaPostgres.mdx index ab3974a31d..cf8a9803fa 100644 --- a/content/100-getting-started/01-quickstart-prismaPostgres.mdx +++ b/content/100-getting-started/01-quickstart-prismaPostgres.mdx @@ -1,7 +1,7 @@ --- title: 'Quickstart' metaTitle: 'Quickstart with TypeScript & Prisma Postgres' -metaDescription: 'Get started with Prisma ORM in 5 minutes. You will learn how to send queries to a SQLite database in a plain TypeScript script using Prisma Client.' +metaDescription: 'Get started with Prisma ORM in 5 minutes. You will learn how to run migrations, send queries and receive real-time updates with a Prisma Postgres database.' search: true sidebar_class_name: hidden-sidebar dbSwitcher: ['sqlite', 'prismaPostgres'] @@ -20,7 +20,7 @@ In this Quickstart guide, you'll learn how to get started from scratch with Pris To successfully complete this tutorial, you need: - a [Prisma Data Platform](https://console.prisma.io/) (PDP) account -- Node.js v16.13.0 or higher (learn more about [system requirements](/orm/reference/system-requirements)) +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) ## 1. Set up a Prisma Postgres database in the Platform Console diff --git a/content/100-getting-started/01-quickstart-sqlite.mdx b/content/100-getting-started/01-quickstart-sqlite.mdx index 2d4e6c53db..4071e1ee4f 100644 --- a/content/100-getting-started/01-quickstart-sqlite.mdx +++ b/content/100-getting-started/01-quickstart-sqlite.mdx @@ -18,7 +18,7 @@ If you want to use Prisma ORM with your own PostgreSQL, MySQL, MongoDB or any ot ## Prerequisites -You need Node.js v16.13.0 or higher for this guide (learn more about [system requirements](/orm/reference/system-requirements)). +You need [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions). ## 1. Create TypeScript project and set up Prisma ORM diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-cockroachdb.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-cockroachdb.mdx index f3626dcc92..73d607b1be 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-cockroachdb.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-cockroachdb.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [CockroachDB](https://www.cockroachlabs.com/) database server running > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-mysql.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-mysql.mdx index 9336d30c3a..3e8130fc94 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-mysql.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-mysql.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [MySQL](https://www.mysql.com/) database server running > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-planetscale.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-planetscale.mdx index 71f1467e5b..cef31fcb4e 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-planetscale.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-planetscale.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PlanetScale](https://planetscale.com/) database server running diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-postgresql.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-postgresql.mdx index 0226f57722..8a456799f8 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-postgresql.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-postgresql.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PostgreSQL](https://www.postgresql.org/) database server running > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-sqlserver.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-sqlserver.mdx index 4a03f6d34d..30047e3686 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-sqlserver.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-node-sqlserver.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - A [Microsoft SQL Server](https://learn.microsoft.com/en-us/sql/?view=sql-server-ver16) database - [Microsoft SQL Server on Linux for Docker](/orm/overview/databases/sql-server/sql-server-docker) - [Microsoft SQL Server on Windows (local)](/orm/overview/databases/sql-server/sql-server-local) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-cockroachdb.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-cockroachdb.mdx index 2ee6b05f1b..8d240309ce 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-cockroachdb.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-cockroachdb.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [CockroachDB](https://www.cockroachlabs.com/) database server running > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-mysql.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-mysql.mdx index 2e0b89564d..3fbca53bbe 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-mysql.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-mysql.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [MySQL](https://www.mysql.com/) database server running > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-planetscale.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-planetscale.mdx index d1c9ead83f..b48752c76c 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-planetscale.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-planetscale.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PlanetScale](https://planetscale.com/) database server running diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-postgresql.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-postgresql.mdx index 139ff6a2aa..d7947f61e8 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-postgresql.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-postgresql.mdx @@ -16,7 +16,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PostgreSQL](https://www.postgresql.org/) database server running > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-prismaPostgres.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-prismaPostgres.mdx index 20a5d208fc..98e3bfa222 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-prismaPostgres.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-prismaPostgres.mdx @@ -23,9 +23,7 @@ Learn how to create a new TypeScript project with a Prisma Postgres database fro To successfully complete this tutorial, you need: - a [Prisma Data Platform](https://console.prisma.io/) (PDP) account -- Node.js v16.13.0 or higher (learn more about [system requirements](/orm/reference/system-requirements)) - -> See [System requirements](/orm/reference/system-requirements) for exact version requirements. +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) (see [system requirements](/orm/reference/system-requirements) for officially supported versions) ## Create project setup diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-sqlserver.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-sqlserver.mdx index 8639b1618c..143b6ef8e8 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-sqlserver.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases-typescript-sqlserver.mdx @@ -21,7 +21,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - A [Microsoft SQL Server](https://learn.microsoft.com/en-us/sql/?view=sql-server-ver16) database - [Microsoft SQL Server on Linux for Docker](/orm/overview/databases/sql-server/sql-server-docker) - [Microsoft SQL Server on Windows (local)](/orm/overview/databases/sql-server/sql-server-local) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-node-mongodb.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-node-mongodb.mdx index e2fa343652..7733b53100 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-node-mongodb.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-node-mongodb.mdx @@ -17,7 +17,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - Access to a MongoDB 4.2+ server with a replica set deployment. We recommend using [MongoDB Atlas](https://www.mongodb.com/cloud/atlas). diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-typescript-mongodb.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-typescript-mongodb.mdx index 7dbe7cf2c0..c6a8250f6f 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-typescript-mongodb.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb-typescript-mongodb.mdx @@ -16,7 +16,7 @@ Learn how to create a new Node.js or TypeScript project from scratch by connecti In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - Access to a MongoDB 4.2+ server with a replica set deployment. We recommend using [MongoDB Atlas](https://www.mongodb.com/cloud/atlas). diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-cockroachdb.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-cockroachdb.mdx index f7c42b7613..0311deeebb 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-cockroachdb.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-cockroachdb.mdx @@ -28,7 +28,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [CockroachDB](https://www.cockroachlabs.com) database server running and a database with at least one table > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-mysql.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-mysql.mdx index 91a13d35e0..89fc9b78ae 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-mysql.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-mysql.mdx @@ -28,7 +28,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [MySQL](https://www.mysql.com/) database server running and a database with at least one table diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-planetscale.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-planetscale.mdx index 9ca61c6778..aefe62a6d4 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-planetscale.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-planetscale.mdx @@ -28,7 +28,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PlanetScale](https://planetscale.com/) database server running and a database with at least one table > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-postgresql.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-postgresql.mdx index 1a4a53cc2f..ea694db247 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-postgresql.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-postgresql.mdx @@ -29,7 +29,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PostgreSQL](https://www.postgresql.org/) database server running and a database with at least one table > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-sqlserver.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-sqlserver.mdx index e335d940ce..3360130fb1 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-sqlserver.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-node-sqlserver.mdx @@ -27,7 +27,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - A [Microsoft SQL Server](https://learn.microsoft.com/en-us/sql/?view=sql-server-ver16) database - [Microsoft SQL Server on Linux for Docker](/orm/overview/databases/sql-server/sql-server-docker) - [Microsoft SQL Server on Windows (local)](/orm/overview/databases/sql-server/sql-server-local) diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-cockroachdb.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-cockroachdb.mdx index 9d71b15f6b..ca51079918 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-cockroachdb.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-cockroachdb.mdx @@ -29,7 +29,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [CockroachDB](https://www.cockroachlabs.com) database server running and a database with at least one table > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-mysql.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-mysql.mdx index 1cdc28a5c6..ca47f85890 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-mysql.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-mysql.mdx @@ -28,7 +28,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [MySQL](https://www.mysql.com/) database server running and a database with at least one table > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-planetscale.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-planetscale.mdx index 5a6839105b..15d9e00681 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-planetscale.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-planetscale.mdx @@ -28,7 +28,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PlanetScale](https://planetscale.com/) database server running and a database with at least one table > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-postgresql.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-postgresql.mdx index 6072b18b7b..5d47271aaa 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-postgresql.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-postgresql.mdx @@ -28,7 +28,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: - an existing Node.js project with a `package.json` -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - a [PostgreSQL](https://www.postgresql.org/) database server running and a database with at least one table > See [System requirements](/orm/reference/system-requirements) for exact version requirements. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-sqlserver.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-sqlserver.mdx index 8732c7c815..cf3389241a 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-sqlserver.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases-typescript-sqlserver.mdx @@ -27,7 +27,7 @@ If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeOR In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - A [Microsoft SQL Server](https://learn.microsoft.com/en-us/sql/?view=sql-server-ver16) database - [Microsoft SQL Server on Linux for Docker](/orm/overview/databases/sql-server/sql-server-docker) - [Microsoft SQL Server on Windows (local)](/orm/overview/databases/sql-server/sql-server-local) diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-node-mongodb.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-node-mongodb.mdx index 24432a3d00..e8c864d300 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-node-mongodb.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-node-mongodb.mdx @@ -23,7 +23,7 @@ If you're migrating to Prisma ORM from Mongoose, see our [Migrate from Mongoose In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - Access to a MongoDB 4.2+ server with a replica set deployment. We recommend using [MongoDB Atlas](https://www.mongodb.com/cloud/atlas). diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-typescript-mongodb.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-typescript-mongodb.mdx index c7dd74d95b..2e7e0f22a8 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-typescript-mongodb.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb-typescript-mongodb.mdx @@ -23,7 +23,7 @@ If you're migrating to Prisma ORM from Mongoose, see our [Migrate from Mongoose In order to successfully complete this guide, you need: -- [Node.js](https://nodejs.org/en/) installed on your machine +- [Node.js](https://nodejs.org/en/) installed on your machine (see [system requirements](/orm/reference/system-requirements) for officially supported versions) - Access to a MongoDB 4.2+ server with a replica set deployment. We recommend using [MongoDB Atlas](https://www.mongodb.com/cloud/atlas). diff --git a/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx b/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx index ab84467e76..3c874a5caa 100644 --- a/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx +++ b/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx @@ -390,12 +390,12 @@ In [3.5.0+](https://github.com/prisma/prisma/releases/3.5.0) for PostgreSQL and This feature is further explain in [the PostgreSQL documentation](https://www.postgresql.org/docs/12/textsearch-controls.html) and [the MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html). -Enable order by relevance with the `fullTextSearch` [preview feature](/orm/prisma-client/queries/full-text-search): +**For PostgreSQL**, you need to enable order by relevance with the `fullTextSearchPostgres` [preview feature](/orm/prisma-client/queries/full-text-search): ```prisma generator client { provider = "prisma-client-js" - previewFeatures = ["fullTextSearch"] + previewFeatures = ["fullTextSearchPostgres"] } ``` diff --git a/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx b/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx index afb5d133b0..ef473c95b8 100644 --- a/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx +++ b/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx @@ -5,32 +5,27 @@ metaDescription: 'This page explains how to search for text within a field.' sidebar_class_name: preview-badge --- -Prisma Client supports full-text search for **PostgreSQL** databases in versions 2.30.0 and later, and **MySQL** databases in versions 3.8.0 and later. With full-text search enabled, you can add search functionality to your application by searching for text within a database column. +Prisma Client supports full-text search for **PostgreSQL** databases in versions 2.30.0 and later, and **MySQL** databases in versions 3.8.0 and later. With full-text search (FTS) enabled, you can add search functionality to your application by searching for text within a database column. -> **Note**: There currently is a [known issue](https://github.com/prisma/prisma/issues/23627) in the full-text search feature. If you observe slow search queries, you can [optimize your query with raw SQL](#full-text-search-with-raw-sql). +:::info -## Enabling full-text search +In Prisma v6, FTS has been [promoted to General Availability on MySQL](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6#fulltextsearch). It still remains in Preview for PostgreSQL and requires using the [`fullTextSearchPostgres`](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6#full-text-search-on-postgresql) Preview feature flag. + +::: + +## Enabling full-text search for PostgreSQL The full-text search API is currently a Preview feature. To enable this feature, carry out the following steps: -1. Update the [`previewFeatures`](/orm/reference/preview-features) block in your schema to include the `fullTextSearch` preview feature flag: +1. Update the [`previewFeatures`](/orm/reference/preview-features) block in your schema to include the `fullTextSearchPostgres` preview feature flag: ```prisma file=schema.prisma showLineNumbers generator client { provider = "prisma-client-js" - previewFeatures = ["fullTextSearch"] + previewFeatures = ["fullTextSearchPostgres"] } ``` - For MySQL, you will also need to include the `fullTextIndex` preview feature flag: - - ```prisma file=schema.prisma highlight=3;add showLineNumbers - generator client { - provider = "prisma-client-js" - //add-next-line - previewFeatures = ["fullTextSearch", "fullTextIndex"] - } - ``` 2. Generate Prisma Client: @@ -51,6 +46,8 @@ const result = await prisma.posts.findMany({ }) ``` +> **Note**: There currently is a [known issue](https://github.com/prisma/prisma/issues/23627) in the full-text search feature for PostgreSQL. If you observe slow search queries, you can [optimize your query with raw SQL](#full-text-search-with-raw-sql). + ## Querying the database The `search` field uses the database's native querying capabilities under the hood. This means that the exact query operators available are also database-specific. @@ -196,14 +193,13 @@ Prisma Client does not currently support using indexes to speed up full text sea ### MySQL -For MySQL, it is necessary to add indexes to any columns you search using the `@@fulltext` argument in the `schema.prisma` file. To do this, the `"fullTextIndex"` preview feature must be enabled. +For MySQL, it is necessary to add indexes to any columns you search using the `@@fulltext` argument in the `schema.prisma` file. In the following example, one full text index is added to the `content` field of the `Blog` model, and another is added to both the `content` and `title` fields together: ```prisma file=schema.prisma showLineNumbers generator client { provider = "prisma-client-js" - previewFeatures = ["fullTextSearch", "fullTextIndex"] } model Blog { diff --git a/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx b/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx index ddc33724c4..e2816e2ac0 100644 --- a/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx +++ b/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx @@ -1,12 +1,12 @@ --- -title: 'Raw queries' -metaTitle: 'Raw queries' -metaDescription: 'Learn how you can send raw SQL and MongoDB queries to your database using the raw() methods from the Prisma Client API.' +title: "Raw queries" +metaTitle: "Raw queries" +metaDescription: "Learn how you can send raw SQL and MongoDB queries to your database using the raw() methods from the Prisma Client API." --- :::warning -With Prisma ORM `5.19.0`, we have released [TypedSQL](/orm/prisma-client/using-raw-sql). TypedSQL is a new way to write SQL queries that are type-safe and even easier to add to your workflow. +With Prisma ORM `5.19.0`, we have released [TypedSQL](/orm/prisma-client/using-raw-sql). TypedSQL is a new way to write SQL queries that are type-safe and even easier to add to your workflow. We strongly recommend using TypedSQL queries over the legacy raw queries described below whenever possible. @@ -32,7 +32,7 @@ For relational databases, Prisma Client exposes four methods that allow you to s - `$executeRawUnsafe` to return a count of affected rows (for example, after an `UPDATE` or `DELETE`) using a raw string. The methods with "Unsafe" in the name are a lot more flexible but are at **significant risk of making your code vulnerable to SQL injection**. - + The other two methods are safe to use with a simple template tag, no string building, and no concatenation. **However**, caution is required for more complex use cases as it is still possible to introduce SQL injection if these methods are used in certain ways. For more details, see the [SQL injection prevention](#sql-injection-prevention) section below. > **Note**: All methods in the above list can only run **one** query at a time. You cannot append a second query - for example, calling any of them with `select 1; select 2;` will not work. @@ -42,23 +42,21 @@ The other two methods are safe to use with a simple template tag, no string buil `$queryRaw` returns actual database records. For example, the following `SELECT` query returns all fields for each record in the `User` table: ```ts no-lines -const result = await prisma.$queryRaw`SELECT * FROM User` +const result = await prisma.$queryRaw`SELECT * FROM User`; ``` The method is implemented as a [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates), which allows you to pass a template literal where you can easily insert your [variables](#using-variables). In turn, Prisma Client creates prepared statements that are safe from SQL injections: ```ts no-lines -const email = 'emelie@prisma.io' -const result = await prisma.$queryRaw`SELECT * FROM User WHERE email = ${email}` +const email = "emelie@prisma.io"; +const result = await prisma.$queryRaw`SELECT * FROM User WHERE email = ${email}`; ``` You can also use the [`Prisma.sql`](#tagged-template-helpers) helper, in fact, the `$queryRaw` method will **only accept** a template string or the `Prisma.sql` helper: ```ts no-lines -const email = 'emelie@prisma.io' -const result = await prisma.$queryRaw( - Prisma.sql`SELECT * FROM User WHERE email = ${email}` -) +const email = "emelie@prisma.io"; +const result = await prisma.$queryRaw(Prisma.sql`SELECT * FROM User WHERE email = ${email}`); ``` @@ -74,32 +72,32 @@ Be aware that: - Template variables cannot be used inside SQL string literals. For example, the following query would **not** work: ```ts no-lines - const name = 'Bob' - await prisma.$queryRaw`SELECT 'My name is ${name}';` + const name = "Bob"; + await prisma.$queryRaw`SELECT 'My name is ${name}';`; ``` Instead, you can either pass the whole string as a variable, or use string concatenation: ```ts no-lines - const name = 'My name is Bob' - await prisma.$queryRaw`SELECT ${name};` + const name = "My name is Bob"; + await prisma.$queryRaw`SELECT ${name};`; ``` ```ts no-lines - const name = 'Bob' - await prisma.$queryRaw`SELECT 'My name is ' || ${name};` + const name = "Bob"; + await prisma.$queryRaw`SELECT 'My name is ' || ${name};`; ``` - Template variables can only be used for data values (such as `email` in the example above). Variables cannot be used for identifiers such as column names, table names or database names, or for SQL keywords. For example, the following two queries would **not** work: ```ts no-lines - const myTable = 'user' - await prisma.$queryRaw`SELECT * FROM ${myTable};` + const myTable = "user"; + await prisma.$queryRaw`SELECT * FROM ${myTable};`; ``` ```ts no-lines - const ordering = 'desc' - await prisma.$queryRaw`SELECT * FROM Table ORDER BY ${ordering};` + const ordering = "desc"; + await prisma.$queryRaw`SELECT * FROM Table ORDER BY ${ordering};`; ``` - Prisma maps any database values returned by `$queryRaw` and `$queryRawUnsafe` to their corresponding JavaScript types. [Learn more](#raw-query-type-mapping). @@ -112,8 +110,8 @@ Be aware that: ```json5 [ - { id: 1, email: 'emelie@prisma.io', name: 'Emelie' }, - { id: 2, email: 'yin@prisma.io', name: 'Yin' }, + { id: 1, email: "emelie@prisma.io", name: "Emelie" }, + { id: 2, email: "yin@prisma.io", name: "Yin" }, ] ``` @@ -131,9 +129,9 @@ $queryRaw(query: TemplateStringsArray | Prisma.Sql, ...values: any[ ```ts // import the generated `User` type from the `@prisma/client` module -import { User } from '@prisma/client' +import { User } from "@prisma/client"; -const result = await prisma.$queryRaw`SELECT * FROM User` +const result = await prisma.$queryRaw`SELECT * FROM User`; // result is of type: `User[]` ``` @@ -158,11 +156,11 @@ model Post { The following query returns all posts. It then prints out the value of the `published` field for each `Post`: ```ts -const result = await prisma.$queryRaw`SELECT * FROM Post` +const result = await prisma.$queryRaw`SELECT * FROM Post`; result.forEach((x) => { - console.log(x.published) -}) + console.log(x.published); +}); ``` For regular CRUD queries, the Prisma Client query engine standardizes the return type for all databases. **Using the raw queries does not**. If the database provider is MySQL, the returned values are `1` or `0`. However, if the database provider is PostgreSQL, the values are `true` or `false`. @@ -174,8 +172,8 @@ For regular CRUD queries, the Prisma Client query engine standardizes the return [It is not possible to interpolate table names](#considerations). This means that you cannot use dynamic table names with `$queryRaw`. Instead, you must use [`$queryRawUnsafe`](#queryrawunsafe), as follows: ```ts -let userTable = 'User' -let result = await prisma.$queryRawUnsafe(`SELECT * FROM ${userTable}`) +let userTable = "User"; +let result = await prisma.$queryRawUnsafe(`SELECT * FROM ${userTable}`); ``` Note that if you use `$queryRawUnsafe` in conjunction with user inputs, you risk SQL injection attacks. [Learn more](#queryrawunsafe). @@ -196,18 +194,15 @@ The following query returns all fields for each record in the `User` table: ```ts // import the generated `User` type from the `@prisma/client` module -import { User } from '@prisma/client' +import { User } from "@prisma/client"; -const result = await prisma.$queryRawUnsafe('SELECT * FROM User') +const result = await prisma.$queryRawUnsafe("SELECT * FROM User"); ``` You can also run a parameterized query. The following example returns all users whose email contains the string `emelie@prisma.io`: ```ts -prisma.$queryRawUnsafe( - 'SELECT * FROM users WHERE email = $1', - 'emelie@prisma.io' -) +prisma.$queryRawUnsafe("SELECT * FROM users WHERE email = $1", "emelie@prisma.io"); ``` > **Note**: Prisma sends JavaScript integers to PostgreSQL as `INT8`. This might conflict with your user-defined functions that accept only `INT4` as input. If you use a parameterized `$queryRawUnsafe` query in conjunction with a PostgreSQL database, update the input types to `INT8`, or cast your query parameters to `INT4`. @@ -226,17 +221,17 @@ $queryRawUnsafe(query: string, ...values: any[]): PrismaPromise; ```ts const result: number = - await prisma.$executeRaw`UPDATE User SET active = true WHERE emailValidated = true` + await prisma.$executeRaw`UPDATE User SET active = true WHERE emailValidated = true`; ``` The method is implemented as a [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates), which allows you to pass a template literal where you can easily insert your [variables](#using-variables). In turn, Prisma Client creates prepared statements that are safe from SQL injections: ```ts -const emailValidated = true -const active = true +const emailValidated = true; +const active = true; const result: number = - await prisma.$executeRaw`UPDATE User SET active = ${active} WHERE emailValidated = ${emailValidated};` + await prisma.$executeRaw`UPDATE User SET active = ${active} WHERE emailValidated = ${emailValidated};`; ``` @@ -255,32 +250,32 @@ Be aware that: - Template variables cannot be used inside SQL string literals. For example, the following query would **not** work: ```ts no-lines - const name = 'Bob' - await prisma.$executeRaw`UPDATE user SET greeting = 'My name is ${name}';` + const name = "Bob"; + await prisma.$executeRaw`UPDATE user SET greeting = 'My name is ${name}';`; ``` Instead, you can either pass the whole string as a variable, or use string concatenation: ```ts no-lines - const name = 'My name is Bob' - await prisma.$executeRaw`UPDATE user SET greeting = ${name};` + const name = "My name is Bob"; + await prisma.$executeRaw`UPDATE user SET greeting = ${name};`; ``` ```ts no-lines - const name = 'Bob' - await prisma.$executeRaw`UPDATE user SET greeting = 'My name is ' || ${name};` + const name = "Bob"; + await prisma.$executeRaw`UPDATE user SET greeting = 'My name is ' || ${name};`; ``` - Template variables can only be used for data values (such as `email` in the example above). Variables cannot be used for identifiers such as column names, table names or database names, or for SQL keywords. For example, the following two queries would **not** work: ```ts no-lines - const myTable = 'user' - await prisma.$executeRaw`UPDATE ${myTable} SET active = true;` + const myTable = "user"; + await prisma.$executeRaw`UPDATE ${myTable} SET active = true;`; ``` ```ts no-lines - const ordering = 'desc' - await prisma.$executeRaw`UPDATE User SET active = true ORDER BY ${desc};` + const ordering = "desc"; + await prisma.$executeRaw`UPDATE User SET active = true ORDER BY ${desc};`; ``` #### Return type @@ -308,22 +303,22 @@ Wherever possible you should use the `$executeRaw` method instead. When used cor The following example uses a template string to update records in the database. It then returns a count of the number of records that were updated: ```ts -const emailValidated = true -const active = true +const emailValidated = true; +const active = true; const result = await prisma.$executeRawUnsafe( `UPDATE User SET active = ${active} WHERE emailValidated = ${emailValidated}` -) +); ``` The same can be written as a parameterized query: ```ts const result = prisma.$executeRawUnsafe( - 'UPDATE User SET active = $1 WHERE emailValidated = $2', - 'yin@prisma.io', + "UPDATE User SET active = $1 WHERE emailValidated = $2", + "yin@prisma.io", true -) +); ``` For more details on using parameterized queries, see the [parameterized queries](#parameterized-queries) section below. @@ -354,10 +349,9 @@ As an example, take a raw query that selects columns with `BigInt`, `Bytes`, `De ```ts -const result = - await prisma.$queryRaw`SELECT bigint, bytes, decimal, date FROM "Table";` +const result = await prisma.$queryRaw`SELECT bigint, bytes, decimal, date FROM "Table";`; -console.log(result) +console.log(result); ``` @@ -365,7 +359,7 @@ console.log(result) ```terminal no-copy wrap -{ bigint: BigInt("123"), bytes: Buffer.from([1, 2]), decimal: Decimal("12.34"), date: Date("") } +{ bigint: BigInt("123"), bytes: ), decimal: Decimal("12.34"), date: Date("") } ``` @@ -376,21 +370,21 @@ In the `result` object, the database values have been mapped to the correspondin The following table shows the conversion between types used in the database and the JavaScript type returned by the raw query: -| Database type | JavaScript type | -| ----------------------- | --------------- | -| Text | `String` | -| 32-bit integer | `Number` | -| Floating point number | `Number` | -| Double precision number | `Number` | -| 64-bit integer | `BigInt` | -| Decimal / numeric | `Decimal` | -| Bytes | `Buffer` | -| Json | `Object` | -| DateTime | `Date` | -| Date | `Date` | -| Time | `Date` | -| Uuid | `String` | -| Xml | `String` | +| Database type | JavaScript type | +| ----------------------- | ----------------------------------------------------------------------------------------------------------------------- | +| Text | `String` | +| 32-bit integer | `Number` | +| Floating point number | `Number` | +| Double precision number | `Number` | +| 64-bit integer | `BigInt` | +| Decimal / numeric | `Decimal` | +| Bytes | `Uint8Array` ([before v6](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6#usage-of-buffer): `Buffer`) | +| Json | `Object` | +| DateTime | `Date` | +| Date | `Date` | +| Time | `Date` | +| Uuid | `String` | +| Xml | `String` | Note that the exact name for each database type will vary between databases – for example, the boolean type is known as `boolean` in PostgreSQL and `STRING` in CockroachDB. See the [Scalar types reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for full details of type names for each database. @@ -401,7 +395,7 @@ Raw queries with Prisma Client might require parameters to be in the expected ty As an example, take the following query using PostgreSQL's `LENGTH` function, which only accepts the `text` type as an input: ```ts -await prisma.$queryRaw`SELECT LENGTH(${42});` +await prisma.$queryRaw`SELECT LENGTH(${42});`; ``` This query returns an error: @@ -414,19 +408,19 @@ This query returns an error: The solution in this case is to explicitly cast `42` to the `text` type: ```ts -await prisma.$queryRaw`SELECT LENGTH(${42}::text);` +await prisma.$queryRaw`SELECT LENGTH(${42}::text);`; ``` :::info **Feature availability:** This funtionality is [Generally Available](/orm/more/releases#generally-available-ga) since version 4.0.0. In v3.14.x and v3.15.x, it was available with the preview feature `improvedQueryRaw`. -For the example above before version 4.0.0, Prisma ORM silently coerces `42` to `text` and does not require the explicit cast. +For the example above before version 4.0.0, Prisma ORM silently coerces `42` to `text` and does not require the explicit cast. On the other hand the following raw query now works correctly, returning an integer result, and failed before: ```ts -await prisma.$queryRaw`SELECT ${1.5}::int as int` +await prisma.$queryRaw`SELECT ${1.5}::int as int`; // Now: [{ int: 2 }] // Before: db error: ERROR: incorrect binary data format in bind parameter 1 @@ -445,8 +439,8 @@ In 2.10.0 and later, you can use `.$executeRaw()` and `.$queryRaw()` inside a [t The following example includes a placeholder named `${userId}`: ```ts -const userId = 42 -const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${userId};` +const userId = 42; +const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${userId};`; ``` ✔ Benefits of using the tagged template versions of `$queryRaw` and `$executeRaw` include: @@ -463,22 +457,21 @@ const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${userId};` Prisma Client specifically uses [SQL Template Tag](https://github.com/blakeembrey/sql-template-tag), which exposes a number of helpers. For example, the following query uses `join()` to pass in a list of IDs: ```ts -import { Prisma } from '@prisma/client' +import { Prisma } from "@prisma/client"; -const ids = [1, 3, 5, 10, 20] -const result = - await prisma.$queryRaw`SELECT * FROM User WHERE id IN (${Prisma.join(ids)})` +const ids = [1, 3, 5, 10, 20]; +const result = await prisma.$queryRaw`SELECT * FROM User WHERE id IN (${Prisma.join(ids)})`; ``` The following example uses the `empty` and `sql` helpers to change the query depending on whether `userName` is empty: ```ts -import { Prisma } from '@prisma/client' +import { Prisma } from "@prisma/client"; -const userName = '' +const userName = ""; const result = await prisma.$queryRaw`SELECT * FROM User ${ userName ? Prisma.sql`WHERE name = ${userName}` : Prisma.empty // Cannot use "" or NULL here! -}` +}`; ``` #### `ALTER` limitation (PostgreSQL) @@ -486,10 +479,8 @@ const result = await prisma.$queryRaw`SELECT * FROM User ${ PostgreSQL [does not support using `ALTER` in a prepared statement](https://www.postgresql.org/docs/current/sql-prepare.html), which means that the following queries **will not work**: ```ts -await prisma.$executeRaw`ALTER USER prisma WITH PASSWORD "${password}"` -await prisma.$executeRaw( - Prisma.sql`ALTER USER prisma WITH PASSWORD "${password}"` -) +await prisma.$executeRaw`ALTER USER prisma WITH PASSWORD "${password}"`; +await prisma.$executeRaw(Prisma.sql`ALTER USER prisma WITH PASSWORD "${password}"`); ``` You can use the following query, but be aware that this is potentially **unsafe** as `${password}` is not escaped: @@ -511,7 +502,7 @@ model Country { The following query on the unsupported field will **not** work: ```tsx -await prisma.$queryRaw`SELECT location FROM Country;` +await prisma.$queryRaw`SELECT location FROM Country;`; ``` Instead, cast `Unsupported` fields to any supported Prisma Client type, **if your `Unsupported` column supports the cast**. @@ -519,7 +510,7 @@ Instead, cast `Unsupported` fields to any supported Prisma Client type, **if you The most common type you may want to cast your `Unsupported` column to is `String`. For example, on PostgreSQL, this would map to the `text` type: ```tsx -await prisma.$queryRaw`SELECT location::text FROM Country;` +await prisma.$queryRaw`SELECT location::text FROM Country;`; ``` The database will thus provide a `String` representation of your data which Prisma Client supports. @@ -541,18 +532,17 @@ This section will provide various examples of using these methods safely and uns These methods can mitigate the risk of SQL injection by escaping all variables when you use tagged templates and sends all queries as prepared statements. ```ts -$queryRaw`...` // Tagged template -$executeRaw`...` // Tagged template +$queryRaw`...`; // Tagged template +$executeRaw`...`; // Tagged template ``` The following example is safe ✅ from SQL Injection: ```ts -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` -const result = - await prisma.$queryRaw`SELECT id, name FROM "User" WHERE name = ${inputString}` +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; +const result = await prisma.$queryRaw`SELECT id, name FROM "User" WHERE name = ${inputString}`; -console.log(result) +console.log(result); ``` #### Unsafe use of `$queryRaw` and `$executeRaw` @@ -565,21 +555,21 @@ The following example is vulnerable ❌ to SQL Injection: ```ts // Unsafely generate query text -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` // SQL Injection -const query = `SELECT id, name FROM "User" WHERE name = ${inputString}` +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; // SQL Injection +const query = `SELECT id, name FROM "User" WHERE name = ${inputString}`; // Version for Typescript -const stringsArray: any = [...[query]] +const stringsArray: any = [...[query]]; // Version for Javascript -const stringsArray = [...[query]] +const stringsArray = [...[query]]; // Use the `raw` property to impersonate a tagged template -stringsArray.raw = [query] +stringsArray.raw = [query]; // Use queryRaw -const result = await prisma.$queryRaw(stringsArray) -console.log(result) +const result = await prisma.$queryRaw(stringsArray); +console.log(result); ``` Another way to make these methods vulnerable is misuse of the `Prisma.raw` function. @@ -587,29 +577,26 @@ Another way to make these methods vulnerable is misuse of the `Prisma.raw` funct The following examples are all vulnerable ❌ to SQL Injection: ```ts -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` -const result = - await prisma.$queryRaw`SELECT id, name FROM "User" WHERE name = ${Prisma.raw( - inputString - )}` -console.log(result) +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; +const result = await prisma.$queryRaw`SELECT id, name FROM "User" WHERE name = ${Prisma.raw( + inputString +)}`; +console.log(result); ``` ```ts -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; const result = await prisma.$queryRaw( Prisma.raw(`SELECT id, name FROM "User" WHERE name = ${inputString}`) -) -console.log(result) +); +console.log(result); ``` ```ts -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` -const query = Prisma.raw( - `SELECT id, name FROM "User" WHERE name = ${inputString}` -) -const result = await prisma.$queryRaw(query) -console.log(result) +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; +const query = Prisma.raw(`SELECT id, name FROM "User" WHERE name = ${inputString}`); +const result = await prisma.$queryRaw(query); +console.log(result); ``` #### Safely using `$queryRaw` and `$executeRaw` in more complex scenarios @@ -622,33 +609,33 @@ In this example, the `sql` helper method is used to build the query text by safe ```ts // inputString can be untrusted input -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; // Safe if the text query below is completely trusted content -const query = Prisma.sql`SELECT id, name FROM "User" WHERE name = ${inputString}` +const query = Prisma.sql`SELECT id, name FROM "User" WHERE name = ${inputString}`; -const result = await prisma.$queryRaw(query) -console.log(result) +const result = await prisma.$queryRaw(query); +console.log(result); ``` In this example which is safe ✅ from SQL Injection, the `sql` helper method is used to build the query text including a parameter marker for the input value. Each variable is represented by a marker symbol (`?` for MySQL, `$1`, `$2`, and so on for PostgreSQL). Note that the examples just show PostgreSQL queries. ```ts // Version for Typescript -const query: any +const query: any; // Version for Javascript -const query +const query; // Safe if the text query below is completely trusted content -query = Prisma.sql`SELECT id, name FROM "User" WHERE name = $1` +query = Prisma.sql`SELECT id, name FROM "User" WHERE name = $1`; // inputString can be untrusted input -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` -query.values = [inputString] +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; +query.values = [inputString]; -const result = await prisma.$queryRaw(query) -console.log(result) +const result = await prisma.$queryRaw(query); +console.log(result); ``` > **Note**: PostgreSQL variables are represented by `$1`, etc @@ -661,13 +648,13 @@ In the following example we have two variables to parameterize. The example is s ```ts // Example is safe if the text query below is completely trusted content -const query1 = `SELECT id, name FROM "User" WHERE name = ` // The first parameter would be inserted after this string -const query2 = ` OR name = ` // The second parameter would be inserted after this string +const query1 = `SELECT id, name FROM "User" WHERE name = `; // The first parameter would be inserted after this string +const query2 = ` OR name = `; // The second parameter would be inserted after this string -const inputString1 = "Fred" -const inputString2 = `'Sarah' UNION SELECT id, title FROM "Post"` +const inputString1 = "Fred"; +const inputString2 = `'Sarah' UNION SELECT id, title FROM "Post"`; -const query = Prisma.sql([query1, query2, ""], inputString1, inputString2) +const query = Prisma.sql([query1, query2, ""], inputString1, inputString2); const result = await prisma.$queryRaw(query); console.log(result); ``` @@ -680,23 +667,23 @@ The following example is safe ✅ from SQL Injection as long as the query string ```ts // Version for Typescript -const query: any +const query: any; // Version for Javascript -const query +const query; // Example is safe if the text query below is completely trusted content -const query1 = `SELECT id, name FROM "User" ` -const query2 = `WHERE name = $1 ` +const query1 = `SELECT id, name FROM "User" `; +const query2 = `WHERE name = $1 `; -query = Prisma.raw(`${query1}${query2}`) +query = Prisma.raw(`${query1}${query2}`); // inputString can be untrusted input -const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` -query.values = [inputString] +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"`; +query.values = [inputString]; -const result = await prisma.$queryRaw(query) -console.log(result) +const result = await prisma.$queryRaw(query); +console.log(result); ``` ### In `$queryRawUnsafe` and `$executeRawUnsafe` @@ -708,11 +695,11 @@ If you cannot use tagged templates, you can instead use [`$queryRawUnsafe`](/orm The following example concatenates `query` and `inputString`. Prisma Client ❌ **cannot** escape `inputString` in this example, which makes it vulnerable to SQL injection: ```ts -const inputString = '"Sarah" UNION SELECT id, title, content FROM Post' // SQL Injection -const query = 'SELECT id, name, email FROM User WHERE name = ' + inputString -const result = await prisma.$queryRawUnsafe(query) +const inputString = '"Sarah" UNION SELECT id, title, content FROM Post'; // SQL Injection +const query = "SELECT id, name, email FROM User WHERE name = " + inputString; +const result = await prisma.$queryRawUnsafe(query); -console.log(result) +console.log(result); ``` #### Parameterized queries @@ -722,13 +709,13 @@ As an alternative to tagged templates, `$queryRawUnsafe` supports standard param The following example is safe ✅ from SQL Injection: ```ts -const userName = 'Sarah' -const email = 'sarah@prisma.io' +const userName = "Sarah"; +const email = "sarah@prisma.io"; const result = await prisma.$queryRawUnsafe( - 'SELECT * FROM User WHERE (name = $1 OR email = $2)', + "SELECT * FROM User WHERE (name = $1 OR email = $2)", userName, email -) +); ``` > **Note**: PostgreSQL variables are represented by `$1` and `$2` @@ -742,13 +729,13 @@ As with tagged templates, Prisma Client escapes all variables when they are prov When you use `ILIKE`, the `%` wildcard character(s) should be included in the variable itself, not the query (`string`). This example is safe ✅ from SQL Injection. ```ts -const userName = 'Sarah' -const emailFragment = 'prisma.io' +const userName = "Sarah"; +const emailFragment = "prisma.io"; const result = await prisma.$queryRawUnsafe( 'SELECT * FROM "User" WHERE (name = $1 OR email ILIKE $2)', userName, `%${emailFragment}` -) +); ``` > **Note**: Using `%$2` as an argument would not work @@ -777,25 +764,25 @@ In the following example, a query inserts two records with the same `_id`. This ```ts no-lines prisma.$runCommandRaw({ - insert: 'Pets', + insert: "Pets", bypassDocumentValidation: true, documents: [ { _id: 1, - name: 'Felinecitas', - type: 'Cat', - breed: 'Russian Blue', + name: "Felinecitas", + type: "Cat", + breed: "Russian Blue", age: 12, }, { _id: 1, - name: 'Nao Nao', - type: 'Dog', - breed: 'Chow Chow', + name: "Nao Nao", + type: "Dog", + breed: "Chow Chow", age: 2, }, ], -}) +}); ``` :::warning @@ -822,7 +809,7 @@ $runCommandRaw(command: InputJsonObject): PrismaPromise; const result = await prisma.user.findRaw({ filter: { age: { $gt: 25 } }, options: { projection: { _id: false } }, -}) +}); ``` #### Return type @@ -845,10 +832,10 @@ const result = await prisma.user.findRaw({ ```ts no-lines const result = await prisma.user.aggregateRaw({ pipeline: [ - { $match: { status: 'registered' } }, - { $group: { _id: '$country', total: { $sum: 1 } } }, + { $match: { status: "registered" } }, + { $group: { _id: "$country", total: { $sum: 1 } } }, ], -}) +}); ``` #### Return type diff --git a/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx b/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx index dfcf3c9cbe..2d448ee8dc 100644 --- a/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx +++ b/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx @@ -66,7 +66,19 @@ JSON.stringify( ## Working with `Bytes` -`Bytes` fields are represented by the [`Buffer`](https://nodejs.org/api/buffer.html) type. The following example demonstrates how to use the `Buffer` type: +`Bytes` fields are represented by the [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) type. The following example demonstrates how to use the `Uint8Array` type: + +```ts +import { PrismaClient, Prisma } from '@prisma/client' + +const newTypes = await prisma.sample.create({ + data: { + myField: new Uint8Array([1, 2, 3, 4]), + }, +}) +``` + +Note that **before Prisma v6**, `Bytes` were represented by the [`Buffer`](https://nodejs.org/api/buffer.html) type: ```ts import { PrismaClient, Prisma } from '@prisma/client' @@ -78,6 +90,9 @@ const newTypes = await prisma.sample.create({ }) ``` +Learn more in the [upgrade guide to v6](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6). + + ## Working with `Json` See: [Working with `Json` fields](/orm/prisma-client/special-fields-and-types/working-with-json-fields) diff --git a/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx b/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx index 845a50cfcc..5aad99108e 100644 --- a/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx +++ b/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx @@ -38,7 +38,7 @@ The following example uses the `client` component to add two methods to Prisma C -To use metrics in your project, you must enable the `metrics` feature flag in the `generator` block of your `schema.prisma` file. [Learn more](/orm/prisma-client/observability-and-logging/metrics#step-2-enable-the-feature-flag-in-the-prisma-schema-file). +To use metrics in your project, you must enable the `metrics` feature flag in the `generator` block of your `schema.prisma` file. [Learn more](/orm/prisma-client/observability-and-logging/metrics#2-enable-the-feature-flag-in-the-prisma-schema-file). diff --git a/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx b/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx index 734eff92aa..bb25a50b20 100644 --- a/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx +++ b/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx @@ -52,10 +52,10 @@ You can [add global labels to your metrics data](#global-labels) to help you gro To use Prisma Client metrics, you must do the following: -1. [Install the appropriate dependencies](#step-1-install-up-to-date-prisma-orm-dependencies). -1. [Enable the `metrics` feature flag in your Prisma schema file](#step-2-enable-the-feature-flag-in-the-prisma-schema-file). +1. [Install the appropriate dependencies](#1-install-up-to-date-prisma-orm-dependencies). +1. [Enable the `metrics` feature flag in your Prisma schema file](#2-enable-the-feature-flag-in-the-prisma-schema-file). -### Step 1. Install up-to-date Prisma ORM dependencies +### 1. Install up-to-date Prisma ORM dependencies Use version `3.15.0` or higher of the `prisma` and `@prisma/client` npm packages. @@ -64,7 +64,7 @@ npm install prisma@latest --save-dev npm install @prisma/client@latest --save ``` -### Step 2: Enable the feature flag in the Prisma schema file +### 2. Enable the feature flag in the Prisma schema file In the `generator` block of your `schema.prisma` file, enable the `metrics` feature flag: diff --git a/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx b/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx index 8d9ce32ab0..707ee123ad 100644 --- a/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx +++ b/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx @@ -6,17 +6,15 @@ sidebar_class_name: preview-badge toc_max_heading_level: 4 --- - Tracing provides a detailed log of the activity that Prisma Client carries out, at an operation level, including the time taken to execute each query. It helps you analyze your application's performance and identify bottlenecks. Tracing is fully compliant with [OpenTelemetry](https://opentelemetry.io/), so you can use it as part of your end-to-end application tracing system. - +:::info Tracing gives you a highly detailed, operation-level insight into your Prisma ORM project. If you want aggregated numerical reporting, such as query counts, connection counts, and total query execution times, see [Metrics](/orm/prisma-client/observability-and-logging/metrics). - +::: - ## About tracing @@ -480,3 +478,4 @@ import { PrismaClient } from '@prisma/client' import async from 'express-async-handler' import express from 'express' ``` + diff --git a/content/200-orm/500-reference/050-prisma-client-reference.mdx b/content/200-orm/500-reference/050-prisma-client-reference.mdx index e1cff6dd46..8ebdd4279c 100644 --- a/content/200-orm/500-reference/050-prisma-client-reference.mdx +++ b/content/200-orm/500-reference/050-prisma-client-reference.mdx @@ -529,7 +529,6 @@ Use model queries to perform CRUD operations on your models. See also: [CRUD](/o | `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | | `omit` | `XOR` | No | Specifies which properties to exclude on the returned object. In [Preview](/orm/more/releases#preview) since 5.13.0 | | `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | -| `rejectOnNotFound` (deprecated) | `RejectOnNotFound` | No | If true, throw a `NotFoundError: No User found error`. You can also [configure `rejectOnNotFound` globally](#rejectonnotfound).

**Note:** `rejectOnNotFound`is deprecated in v4.0.0. From v4.0.0, use [`findUniqueOrThrow`](#finduniqueorthrow) instead. | #### Return type @@ -538,7 +537,6 @@ Use model queries to perform CRUD operations on your models. See also: [CRUD](/o | JavaScript object (typed) | `User` | | | JavaScript object (plain) | `{ title: "Hello world" }` | Use `select` and `include` to determine which fields to return. | | `null` | `null` | Record not found | -| Error | | If `rejectOnNotFound` is true, `findUnique()` throws an error (`NotFoundError` by default, [customizable globally](#rejectonnotfound)) instead of returning `null`. | #### Examples @@ -621,26 +619,23 @@ const result = await prisma.user.findUnique({ ### `findUniqueOrThrow()` -:::note -We introduced `findUniqueOrThrow` in v4.0.0. It replaces the [`rejectOnNotFound`](#rejectonnotfound) option. `rejectOnNotFound` is deprecated in v4.0.0. +`findUniqueOrThrow()` retrieves a single record in the same way as [`findUnique()`](#findunique). However, if the query does not find the requested record, it throws a `PrismaClientKnownRequestError`. -::: +Note that [before Prisma v6](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6#removed-notfounderror), it would throw a `NotFoundError: No User found error`. -`findUniqueOrThrow` retrieves a single data record similarly to [`findUnique()`](#findunique). However, if no record is found, it throws a `NotFoundError` with a message like: `No found`. Here’s an example of its usage: +Here’s an example of its usage: ```ts await prisma.user.findUniqueOrThrow({ - where: { - id: 1, - }, + where: { id: 1 }, }); ``` -`findUniqueOrThrow` differs from `findUnique()` as follows: +`findUniqueOrThrow()` differs from `findUnique()` as follows: - Its return type is non-nullable. For example, `post.findUnique()` can return `post` or `null`, but `post.findUniqueOrThrow()` always returns `post`. -- It is not compatible with sequential operations in the [`$transaction` API](/orm/prisma-client/queries/transactions#the-transaction-api). If the query returns `NotFoundError`, then the API will not roll back any operations in the array of calls. As a workaround, you can use interactive transactions with the `$transaction` API, as follows: +- It is not compatible with sequential operations in the [`$transaction` API](/orm/prisma-client/queries/transactions#the-transaction-api). If the query throws a `PrismaClientKnownRequestError`, then the API will not roll back any operations in the array of calls. As a workaround, you can use interactive transactions with the `$transaction` API, as follows: ```ts $transaction(async (prisma) => { @@ -659,20 +654,14 @@ await prisma.user.findUniqueOrThrow({ #### Options -| Name | Example type (`User`) | Required | Description | -| ------------------------------- | ----------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | -| `omit` | `XOR` | No | Specifies which properties to exclude on the returned object. In [Preview](/orm/more/releases#preview) since 5.13.0. | -| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | -| `where` | `UserWhereInput` | No | Wraps _all_ model fields in a type so that the list can be filtered by any property. | -| `orderBy` | `XOR, UserOrderByInput>` | No | Lets you order the returned list by any property. | -| `cursor` | `UserWhereUniqueInput` | No | Specifies the position for the list (the value typically specifies an `id` or another unique value). | -| `take` | `number` | No | Specifies how many objects should be returned in the list. When used with `findFirst`, `take` is implicitly `1` or `-1`. `findFirst` is only affected by whether the value is positive or negative - any negative value reverses the list. | -| `skip` | `number` | No | Specifies how many of the returned objects in the list should be skipped. | -| `distinct` | `Enumerable` | No | Lets you filter out duplicate rows by a specific field - for example, return only distinct `Post` titles. | -| `rejectOnNotFound` (deprecated) | `RejectOnNotFound` | No | If true, throw a `NotFoundError: No User found error`. You can also [configure `rejectOnNotFound` globally](#rejectonnotfound).

**Note:** `rejectOnNotFound` is deprecated in v4.0.0. From v4.0.0, use [`findFirstOrThrow`](#findfirstorthrow) instead. | - +| Name | Example type (`User`) | Required | Description | +| ---------------------- | ----------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `omit` | `XOR` | No | Specifies which properties to exclude on the returned object. In [Preview](/orm/more/releases#preview) since 5.13.0. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | +| `where` | `UserWhereInput` | No | Wraps _all_ model fields in a type so that the list can be filtered by any property. | +| `orderBy` | `XOR, UserOrderByInput>` | No | Lets you order the returned list by any property. | #### Return type @@ -681,7 +670,6 @@ await prisma.user.findUniqueOrThrow({ | JavaScript object (typed) | `User` | Specifies which properties to include on the returned object. | | JavaScript object (plain) | `{ title: "Hello world" }` | Use `select` and `include` to determine which fields to return. | | `null` | `null` | Record not found | -| Error | | If `rejectOnNotFound` is true, `findUnique()` throws an error (`NotFoundError` by default, [customizable globally](#rejectonnotfound)) instead of returning `null`. | #### Remarks @@ -738,18 +726,14 @@ main(); ### `findFirstOrThrow()` - - -We introduced `findFirstOrThrow` in v4.0.0. It replaces the [`rejectOnNotFound`](#rejectonnotfound) option. `rejectOnNotFound` is deprecated in v4.0.0. +`findFirstOrThrow()` retrieves a single data record in the same way as [`findFirst()`](#findfirst). However, if the query does not find a record, it throws a `PrismaClientKnownRequestError`. - - -`findFirstOrThrow` retrieves the first record in a list in the same way as [`findFirst`](#findfirst). However, if the query does not find a record, it returns `NotFoundError: No User found error`. +Note that [before Prisma v6](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6#removed-notfounderror), it would throw a `NotFoundError: No User found error`. -`findFirstOrThrow` differs from `findFirst` as follows: +`findFirstOrThrow()` differs from `findFirst()` as follows: - Its return type is non-nullable. For example, `post.findFirst()` can return `post` or `null`, but `post.findFirstOrThrow` always returns `post`. -- It is not compatible with sequential operations in the [`$transaction` API](/orm/prisma-client/queries/transactions#the-transaction-api). If the query returns `NotFoundError`, then the API will not roll back any operations in the array of calls. As a workaround, you can use interactive transactions with the `$transaction` API, as follows: +- It is not compatible with sequential operations in the [`$transaction` API](/orm/prisma-client/queries/transactions#the-transaction-api). If the query returns `PrismaClientKnownRequestError`, then the API will not roll back any operations in the array of calls. As a workaround, you can use interactive transactions with the `$transaction` API, as follows: ```ts prisma.$transaction(async (tx) => { @@ -2324,11 +2308,11 @@ const posts = await prisma.post.findMany({ #### Sort `Post` by relevance of the title - +:::info -This feature is available from version 3.5.0 onwards in PostgreSQL and MySQL only. You'll need to use the `fullTextSearch` preview flag to enable this feature. +For PostgreSQL, this feature is still in Preview. [Enable the `fullTextSearchPostgres` feature flag](/orm/prisma-client/queries/full-text-search#enabling-full-text-search-for-postgresql) in order to use it. - +::: The following query orders posts by relevance of the search term `'database'` to the title: @@ -3811,15 +3795,11 @@ const result = await prisma.post.count({ Use [Full-Text Search](/orm/prisma-client/queries/full-text-search) to search within a `String` field. -Full-Text Search is currently in **Preview** and only available for **PostgreSQL** and **MySQL**. To use `search`, you'll need to enable the `fullTextSearch` -preview feature. +:::info -```prisma -generator client { - provider = "prisma-client-js" - previewFeatures = ["fullTextSearch"] -} -``` +For PostgreSQL, this feature is still in Preview. [Enable the `fullTextSearchPostgres` feature flag](/orm/prisma-client/queries/full-text-search#enabling-full-text-search-for-postgresql) in order to use it. + +::: #### Examples diff --git a/content/200-orm/500-reference/100-prisma-schema-reference.mdx b/content/200-orm/500-reference/100-prisma-schema-reference.mdx index fe31f1b308..36f81ad1ec 100644 --- a/content/200-orm/500-reference/100-prisma-schema-reference.mdx +++ b/content/200-orm/500-reference/100-prisma-schema-reference.mdx @@ -1,8 +1,8 @@ --- -title: 'Prisma schema reference' -metaTitle: 'Prisma Schema API' -metaDescription: 'API reference documentation for the Prisma Schema Language (PSL).' -sidebar_label: 'Prisma Schema' +title: "Prisma schema reference" +metaTitle: "Prisma Schema API" +metaDescription: "API reference documentation for the Prisma Schema Language (PSL)." +sidebar_label: "Prisma Schema" tocDepth: 3 toc: true --- @@ -164,7 +164,7 @@ Defines a [generator](/orm/prisma-schema/overview/generators) in the Prisma sche A `generator` block accepts the following fields: | Name | Required | Type | Description | -| ----------------- | -------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ----------------- | -------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | | `provider` | **Yes** | String (file path) or Enum (`prisma-client-js`) | Describes which [generator](/orm/prisma-schema/overview/generators) to use. This can point to a file that implements a generator or specify a built-in generator directly. | | `output` | No | String (file path) | Determines the location for the generated client, [learn more](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path). **Default**: `node_modules/.prisma/client` | | `previewFeatures` | No | List of Enums | Use intellisense to see list of currently available Preview features (`Ctrl+Space` in Visual Studio Code) **Default**: none | | @@ -889,14 +889,14 @@ A JSON object. #### Default type mappings -| Connector | Default mapping | -| ----------- | -------------------------------------------------------------------------------------------------------- | -| PostgreSQL | `jsonb` | -| SQL Server | [Not supported](https://github.com/prisma/prisma/issues/7417) | -| MySQL | `JSON` | +| Connector | Default mapping | +| ----------- | ------------------------------------------------------------------------------------------------------------ | +| PostgreSQL | `jsonb` | +| SQL Server | [Not supported](https://github.com/prisma/prisma/issues/7417) | +| MySQL | `JSON` | | MongoDB | [A valid `BSON` object (Relaxed mode)](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/) | -| SQLite | Not supported | -| CockroachDB | `JSONB` | +| SQLite | Not supported | +| CockroachDB | `JSONB` | #### PostgreSQL @@ -997,9 +997,10 @@ Not supported #### Clients -| Client | Type | Description | -| :--------------- | :--------------------------------------------- | :------------------------------------------------------------------------------------------------------ | -| Prisma Client JS | [`Buffer`](https://nodejs.org/api/buffer.html) | See [examples of working with `Buffer`](/orm/prisma-client/special-fields-and-types#working-with-bytes) | +| Client | Type | Description | +| :------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------- | +| Prisma Client JS | [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | See [examples of working with `Bytes`](/orm/prisma-client/special-fields-and-types#working-with-bytes) | +| Prisma Client JS ([before v6](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6)) | [`Buffer`](https://nodejs.org/api/buffer.html) | See [examples of working with `Bytes`](/orm/prisma-client/special-fields-and-types#working-with-bytes) | ### `Unsupported` @@ -1346,13 +1347,13 @@ name String Note that in the above case, you _must_ provide your own ID values when creating new records for the `User` model using Prisma Client, e.g.: -```ts +```ts const newUser = await prisma.user.create({ data: { id: 1, - name: 'Alice', + name: "Alice", }, -}) +}); ``` ###### Specify an ID on relation scalar field without a default value @@ -1406,15 +1407,15 @@ The following example creates a user and a profile: const userWithProfile = await prisma.user.create({ data: { id: 3, - email: 'bob@prisma.io', - name: 'Bob Prismo', + email: "bob@prisma.io", + name: "Bob Prismo", profile: { create: { bio: "Hello, I'm Bob Prismo and I love apples, blue nail varnish, and the sound of buzzing mosquitoes.", }, }, }, -}) +}); ``` The following example connects a new profile to a user: @@ -1429,7 +1430,7 @@ const profileWithUser = await prisma.profile.create({ }, }, }, -}) +}); ``` ### `@@id` @@ -1502,10 +1503,10 @@ When you create a user, you must provide a unique combination of `firstName` and ```ts const user = await prisma.user.create({ data: { - firstName: 'Alice', - lastName: 'Smith', + firstName: "Alice", + lastName: "Smith", }, -}) +}); ``` To retrieve a user, use the generated composite ID field (`firstName_lastName`): @@ -1514,11 +1515,11 @@ To retrieve a user, use the generated composite ID field (`firstName_lastName`): const user = await prisma.user.findUnique({ where: { firstName_lastName: { - firstName: 'Alice', - lastName: 'Smith', + firstName: "Alice", + lastName: "Smith", }, }, -}) +}); ``` ##### Specify a multi-field ID on two `String` fields and one `Boolean` field (Relational databases only) @@ -1539,11 +1540,11 @@ When creating new `User` records, you now must provide a unique combination of v ```ts const user = await prisma.user.create({ data: { - firstName: 'Alice', - lastName: 'Smith', + firstName: "Alice", + lastName: "Smith", isAdmin: true, }, -}) +}); ``` ##### Specify a multi-field ID that includes a relation field (Relational databases only) @@ -1571,14 +1572,14 @@ When creating new `Post` records, you now must provide a unique combination of v ```ts const post = await prisma.post.create({ data: { - title: 'Hello World', + title: "Hello World", author: { connect: { - email: 'alice@prisma.io', + email: "alice@prisma.io", }, }, }, -}) +}); ``` ### `@default` @@ -2122,7 +2123,7 @@ Defines a compound [unique constraint](/orm/prisma-schema/data-model/models#defi firstname Int lastname Int id Int? - + @@unique([firstname, lastname, id]) } ``` @@ -2152,7 +2153,7 @@ Defines a compound [unique constraint](/orm/prisma-schema/data-model/models#defi #### Arguments | Name | Required | Type | Description | -| ----------- | -------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ----------- | -------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | | `fields` | **Yes** | `FieldReference[]` | A list of field names - for example, `["firstname", "lastname"]`. Fields must be mandatory - see remarks. | | `name` | **No** | `String` | The name of the unique combination of fields - defaults to `fieldName1_fieldName2_fieldName3` | | `map` | **No** | `String` | @@ -2234,12 +2235,12 @@ To retrieve a user, use the generated field name (`firstname_lastname`): const user = await prisma.user.findUnique({ where: { firstName_lastName: { - firstName: 'Alice', - lastName: 'Smith', + firstName: "Alice", + lastName: "Smith", isAdmin: true, }, }, -}) +}); ``` ##### Specify a multi-field unique attribute on two `String` fields and one `Boolean` field @@ -2361,12 +2362,12 @@ To retrieve a user, use the custom field name (`admin_identifier`): const user = await prisma.user.findUnique({ where: { admin_identifier: { - firstName: 'Alice', - lastName: 'Smith', + firstName: "Alice", + lastName: "Smith", isAdmin: true, }, }, -}) +}); ``` ### `@@index` @@ -2519,7 +2520,6 @@ Defines meta information about the relation. [Learn more](/orm/prisma-schema/dat The name of the `name` argument on the `@relation` attribute can be omitted (`references` is required): - ```prisma @relation(name: "UserOnPost", references: [id]) @relation("UserOnPost", references: [id]) @@ -2530,7 +2530,6 @@ The name of the `name` argument on the `@relation` attribute can be omitted (`re @relation("UserOnPost") ``` - #### Signature ```prisma no-lines @@ -2627,9 +2626,9 @@ The generated client: ```ts highlight=3;normal await prisma.user.create({ data: { - firstName: 'Yewande', // first_name --> firstName + firstName: "Yewande", // first_name --> firstName }, -}) +}); ``` ##### Map an enum named `ADMIN` to a database enum named `admin` @@ -2703,9 +2702,9 @@ The generated client: await prisma.user.create({ // users --> user data: { - name: 'Yewande', + name: "Yewande", }, -}) +}); ``` ##### Map the `Role` enum to a native enum in the database named `_Role` its values to lowercase values in the database @@ -2901,9 +2900,7 @@ For more information about using the `multiSchema` feature, refer to [this guide ### `auto()` - - This function is available on MongoDB only. - +This function is available on MongoDB only. Represents **default values** that are automatically generated by the database. @@ -3102,7 +3099,6 @@ If you're also using [`@updatedAt`](/orm/reference/prisma-schema-reference#updat ::: - ##### Relational databases - Implemented on the database-level, meaning that it manifests in the database schema and can be recognized through introspection. Database implementations: diff --git a/content/200-orm/500-reference/400-system-requirements.mdx b/content/200-orm/500-reference/400-system-requirements.mdx index 673fcc4a48..6226c4d734 100644 --- a/content/200-orm/500-reference/400-system-requirements.mdx +++ b/content/200-orm/500-reference/400-system-requirements.mdx @@ -1,16 +1,12 @@ --- -title: 'System requirements' -metaTitle: 'System requirements (Reference)' -metaDescription: 'System requirements for running Prisma ORM' +title: "System requirements" +metaTitle: "System requirements (Reference)" +metaDescription: "System requirements for running Prisma ORM" tocDepth: 3 --- - - This page provides an overview of the system requirements for Prisma ORM. - - ## System requirements This section lists the software that Prisma ORM requires and the supported operating systems, along with runtime dependency requirements for specific operating systems. @@ -19,13 +15,14 @@ This section lists the software that Prisma ORM requires and the supported opera The latest version of Prisma ORM requires the following software: -| | Minimum required version | +| Tool | Minimum required version | | :-------------------- | :----------------------- | -| Node.js | 16.13 / 18.X / 20.X | -| TypeScript (optional) | 4.7.X | +| Node.js | 18.8 / 20.9 / 22.11 | +| TypeScript (optional) | 5.1.X | | Yarn (optional) | 1.19.2 | -Notes: + + - Prisma ORM supports and tests all _Active LTS_ and _Maintenance LTS_ **Node.js** releases. [Releases that are not in these states like _Current_, and also odd-numbered versions](https://nodejs.org/en/about/releases/) probably also work, but are not recommended for production use. - **TypeScript** is only required for TypeScript users. @@ -33,9 +30,24 @@ Notes: See also: [Supported database versions](/orm/reference/supported-databases) +
+Expand for earlier versions + +### Prisma ORM v5 + +Prisma ORM v5 requires the following software: + +| | Minimum required version | +| :-------------------- | :----------------------- | +| Node.js | 16.13 / 18.X / 20.X | +| TypeScript (optional) | 4.7.X | +| Yarn (optional) | 1.19.2 | + +
+ ### Operating systems -Prisma ORM is supported on MacOS, Windows and most Linux distributions. +Prisma ORM is supported on macOS, Windows and most Linux distributions. #### Linux runtime dependencies diff --git a/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx b/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx index 8f3f234551..79b7bcf543 100644 --- a/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx +++ b/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx @@ -1,7 +1,7 @@ --- -title: 'Prisma Client & Prisma schema' -metaTitle: 'Prisma Client & Prisma schema' -metaDescription: 'Prisma Client and Prisma schema features that are currently in Preview.' +title: "Prisma Client & Prisma schema" +metaTitle: "Prisma Client & Prisma schema" +metaDescription: "Prisma Client and Prisma schema features that are currently in Preview." --- @@ -18,10 +18,8 @@ The following [Preview](/orm/more/releases#preview) feature flags are available | Feature | Released into Preview | Feedback issue | | -------------------------------------------------------------------------------------------- | :------------------------------------------------------------- | :-------------------------------------------------------------------: | -| [`fullTextSearch`](/orm/prisma-client/queries/full-text-search) | [2.30.0](https://github.com/prisma/prisma/releases/tag/2.30.0) | [Submit feedback](https://github.com/prisma/prisma/issues/8877) | -| [`fullTextIndex`](/orm/prisma-schema/data-model/indexes#full-text-indexes-mysql-and-mongodb) | [3.6.0](https://github.com/prisma/prisma/releases/tag/3.6.0) | [Submit feedback](https://github.com/prisma/prisma/issues/10539) | +| [`fullTextSearchPostgres`](/orm/prisma-client/queries/full-text-search) | [2.30.0](https://github.com/prisma/prisma/releases/tag/2.30.0) | [Submit feedback](https://github.com/prisma/prisma/issues/8877) | | [`metrics`](/orm/prisma-client/observability-and-logging/metrics) | [3.15.0](https://github.com/prisma/prisma/releases/tag/3.15.0) | [Submit feedback](https://github.com/prisma/prisma/issues/13579) | -| [`tracing`](/orm/prisma-client/observability-and-logging/opentelemetry-tracing) | [4.2.0](https://github.com/prisma/prisma/releases/tag/4.2.0) | [Submit feedback](https://github.com/prisma/prisma/issues/14640) | | [`multiSchema`](https://github.com/prisma/prisma/issues/1122#issuecomment-1231773471) | [4.3.0](https://github.com/prisma/prisma/releases/tag/4.3.0) | [Submit feedback](https://github.com/prisma/prisma/issues/15077) | | [`postgresqlExtensions`](/orm/prisma-schema/postgresql-extensions) | [4.5.0](https://github.com/prisma/prisma/releases/tag/4.5.0) | [Submit feedback](https://github.com/prisma/prisma/issues/15835) | | [`deno`](/orm/prisma-client/deployment/edge/deploy-to-deno-deploy) | [4.5.0](https://github.com/prisma/prisma/releases/tag/4.5.0) | [Submit feedback](https://github.com/prisma/prisma/issues/15844) | @@ -45,7 +43,7 @@ To enable a Prisma Client Preview feature: ```prisma generator client { provider = "prisma-client-js" - previewFeatures = ["fullTextSearch"] + previewFeatures = ["relationJoins"] } ``` @@ -61,36 +59,36 @@ To enable a Prisma Client Preview feature: In the list below, you can find a history of Prisma Client and Prisma schema features that were in Preview and are now in general availability. The features are sorted by the most recent version in which they were promoted to general availability. -| Feature | Released into Preview | Released into General Availability | -| -------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `jsonProtocol` | [4.11.0](https://github.com/prisma/prisma/releases/tag/4.11.0) | [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0) | -| [`extendedWhereUnique`](/orm/reference/prisma-client-reference#filter-on-non-unique-fields-with-userwhereuniqueinput) | [4.5.0](https://github.com/prisma/prisma/releases/tag/4.5.0) | [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0) | -| [`fieldReference`](/orm/reference/prisma-client-reference#compare-columns-in-the-same-table) | [4.3.0](https://github.com/prisma/prisma/releases/tag/4.3.0) | [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0) | -| [`clientExtensions`](/orm/prisma-client/client-extensions) | [4.7.0](https://github.com/prisma/prisma/releases/tag/4.7.0) | [4.16.0](https://github.com/prisma/prisma/releases/tag/4.16.0) | -| [`filteredRelationCount`](/orm/prisma-client/queries/aggregation-grouping-summarizing#filter-the-relation-count) | [4.3.0](https://github.com/prisma/prisma/releases/tag/4.3.0) | [4.16.0](https://github.com/prisma/prisma/releases/tag/4.16.0) | -| [`orderByNulls`](/orm/prisma-client/queries/filtering-and-sorting#sort-with-null-records-first-or-last) | [4.1.0](https://github.com/prisma/prisma/releases/tag/4.1.0) | [4.16.0](https://github.com/prisma/prisma/releases/tag/4.16.0) | -| [`referentialIntegrity`](/orm/prisma-schema/data-model/relations/relation-mode) | [3.1.1](https://github.com/prisma/prisma/releases/tag/3.1.1) | [4.7.0](https://github.com/prisma/prisma/releases/tag/4.7.0) | +| Feature | Released into Preview | Released into General Availability | +| -------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `jsonProtocol` | [4.11.0](https://github.com/prisma/prisma/releases/tag/4.11.0) | [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0) | +| [`extendedWhereUnique`](/orm/reference/prisma-client-reference#filter-on-non-unique-fields-with-userwhereuniqueinput) | [4.5.0](https://github.com/prisma/prisma/releases/tag/4.5.0) | [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0) | +| [`fieldReference`](/orm/reference/prisma-client-reference#compare-columns-in-the-same-table) | [4.3.0](https://github.com/prisma/prisma/releases/tag/4.3.0) | [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0) | +| [`clientExtensions`](/orm/prisma-client/client-extensions) | [4.7.0](https://github.com/prisma/prisma/releases/tag/4.7.0) | [4.16.0](https://github.com/prisma/prisma/releases/tag/4.16.0) | +| [`filteredRelationCount`](/orm/prisma-client/queries/aggregation-grouping-summarizing#filter-the-relation-count) | [4.3.0](https://github.com/prisma/prisma/releases/tag/4.3.0) | [4.16.0](https://github.com/prisma/prisma/releases/tag/4.16.0) | +| [`orderByNulls`](/orm/prisma-client/queries/filtering-and-sorting#sort-with-null-records-first-or-last) | [4.1.0](https://github.com/prisma/prisma/releases/tag/4.1.0) | [4.16.0](https://github.com/prisma/prisma/releases/tag/4.16.0) | +| [`referentialIntegrity`](/orm/prisma-schema/data-model/relations/relation-mode) | [3.1.1](https://github.com/prisma/prisma/releases/tag/3.1.1) | [4.7.0](https://github.com/prisma/prisma/releases/tag/4.7.0) | | [`interactiveTransactions`](/orm/prisma-client/queries/transactions#interactive-transactions) | [2.29.0](https://github.com/prisma/prisma/releases/tag/2.29.0) |
  • [4.7.0](https://github.com/prisma/prisma/releases/tag/4.7.0)
  • with Prisma Accelerate [5.1.1](https://github.com/prisma/prisma/releases/tag/5.1.1)
| -| [`extendedIndexes`](/orm/prisma-schema/data-model/indexes) | [3.5.0](https://github.com/prisma/prisma/releases/tag/3.5.0) | [4.0.0](https://github.com/prisma/prisma/releases/tag/4.0.0) | -| [`filterJson`](/orm/prisma-client/special-fields-and-types/working-with-json-fields#filter-on-a-json-field-simple) | [2.23.0](https://github.com/prisma/prisma/releases/tag/2.23.0) | [4.0.0](https://github.com/prisma/prisma/releases/tag/4.0.0) | -| [`improvedQueryRaw`](/orm/prisma-client/using-raw-sql/raw-queries#raw-query-type-mapping) | [3.14.0](https://github.com/prisma/prisma/releases/tag/3.14.0) | [4.0.0](https://github.com/prisma/prisma/releases/tag/4.0.0) | -| [`cockroachdb`](/orm/overview/databases/cockroachdb) |
  • [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0)
  • migrations in CockroachDB in [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0)
| [3.14.0](https://github.com/prisma/prisma/releases/tag/3.14.0) | -| [`mongodb`](/orm/overview/databases/mongodb) |
  • [2.27.0](https://github.com/prisma/prisma/releases/tag/2.27.0)
  • introspection of MongoDB in [3.2.0](https://github.com/prisma/prisma/releases/tag/3.2.0)
  • introspection of embedded documents in [3.4.0](https://github.com/prisma/prisma/releases/tag/3.4.0)
  • MongoDB embedded documents in [3.10.0](https://github.com/prisma/prisma/releases/tag/3.10.0)
  • introspection of embedded documents in [3.10.0](https://github.com/prisma/prisma/releases/tag/3.10.0)
  • raw query support for MongoDB in [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0)
  • filters in embedded documents as an Experimental Feature in [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0)
  • order by embedded documents in [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0)
| [3.12.0](https://github.com/prisma/prisma/releases/tag/3.12.0) | -| [`microsoftSqlServer`](/orm/overview/databases/sql-server) | [2.10.0](https://github.com/prisma/prisma/releases/tag/2.10.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | -| [`namedConstraints`](/orm/prisma-schema/data-model/database-mapping#constraint-and-index-names) | [2.29.0](https://github.com/prisma/prisma/releases/tag/2.29.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | -| [`referentialActions`](/orm/prisma-schema/data-model/relations/referential-actions) | [2.26.0](https://github.com/prisma/prisma/releases/tag/2.26.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | -| [`orderByAggregateGroup`](/orm/prisma-client/queries/aggregation-grouping-summarizing#order-by-aggregate-group) | [2.21.0](https://github.com/prisma/prisma/releases/tag/2.21.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | -| [`orderByRelation`](/orm/prisma-client/queries/filtering-and-sorting#sort-by-relation) |
  • [2.16.0](https://github.com/prisma/prisma/releases/tag/2.16.0)
  • order by aggregates of relations in [2.19.0](https://github.com/prisma/prisma/releases/tag/2.19.0)
| [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | -| [`selectRelationCount`](/orm/prisma-client/queries/aggregation-grouping-summarizing#count-relations) | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | -| `napi` | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | -| [`groupBy`](/orm/reference/prisma-client-reference#groupby) | [2.14.0](https://github.com/prisma/prisma/releases/tag/2.14.0) | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | -| [`createMany`](/orm/reference/prisma-client-reference#createmany) | [2.16.0](https://github.com/prisma/prisma/releases/tag/2.16.0) | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | -| [`nativeTypes`](/orm/prisma-schema/data-model/models#native-types-mapping) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) | -| [`uncheckedScalarInputs`](/orm/prisma-client/queries/relation-queries#create-a-single-record-and-multiple-related-records) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | [2.15.0](https://github.com/prisma/prisma/releases/tag/2.15.0) | -| [`transactionApi`](/orm/prisma-client/queries/transactions#the-transaction-api) | [2.1.0](https://github.com/prisma/prisma/releases/tag/2.1.0) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | -| [`connectOrCreate`](/orm/reference/prisma-client-reference#connectorcreate) | [2.1.0](https://github.com/prisma/prisma/releases/tag/2.1.0) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | -| [`atomicNumberOperations`](/orm/reference/prisma-client-reference#atomic-number-operations) | [2.6.0](https://github.com/prisma/prisma/releases/tag/2.6.0) | [2.10.0](https://github.com/prisma/prisma/releases/tag/2.10.0) | -| [`insensitiveFilters` (PostgreSQL)](/orm/prisma-client/queries/filtering-and-sorting#case-insensitive-filtering) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | [2.8.0](https://github.com/prisma/prisma/releases/tag/2.8.0) | -| [`middlewares`](/orm/prisma-client/client-extensions/middleware) | [2.3.0](https://github.com/prisma/prisma/releases/tag/2.3.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | -| [`aggregateApi`](/orm/prisma-client/queries/aggregation-grouping-summarizing#aggregate) | [2.2.0](https://github.com/prisma/prisma/releases/tag/2.2.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | -| [`distinct`](/orm/reference/prisma-client-reference#distinct) | [2.3.0](https://github.com/prisma/prisma/releases/tag/2.3.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | +| [`extendedIndexes`](/orm/prisma-schema/data-model/indexes) | [3.5.0](https://github.com/prisma/prisma/releases/tag/3.5.0) | [4.0.0](https://github.com/prisma/prisma/releases/tag/4.0.0) | +| [`filterJson`](/orm/prisma-client/special-fields-and-types/working-with-json-fields#filter-on-a-json-field-simple) | [2.23.0](https://github.com/prisma/prisma/releases/tag/2.23.0) | [4.0.0](https://github.com/prisma/prisma/releases/tag/4.0.0) | +| [`improvedQueryRaw`](/orm/prisma-client/using-raw-sql/raw-queries#raw-query-type-mapping) | [3.14.0](https://github.com/prisma/prisma/releases/tag/3.14.0) | [4.0.0](https://github.com/prisma/prisma/releases/tag/4.0.0) | +| [`cockroachdb`](/orm/overview/databases/cockroachdb) |
  • [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0)
  • migrations in CockroachDB in [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0)
| [3.14.0](https://github.com/prisma/prisma/releases/tag/3.14.0) | +| [`mongodb`](/orm/overview/databases/mongodb) |
  • [2.27.0](https://github.com/prisma/prisma/releases/tag/2.27.0)
  • introspection of MongoDB in [3.2.0](https://github.com/prisma/prisma/releases/tag/3.2.0)
  • introspection of embedded documents in [3.4.0](https://github.com/prisma/prisma/releases/tag/3.4.0)
  • MongoDB embedded documents in [3.10.0](https://github.com/prisma/prisma/releases/tag/3.10.0)
  • introspection of embedded documents in [3.10.0](https://github.com/prisma/prisma/releases/tag/3.10.0)
  • raw query support for MongoDB in [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0)
  • filters in embedded documents as an Experimental Feature in [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0)
  • order by embedded documents in [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0)
| [3.12.0](https://github.com/prisma/prisma/releases/tag/3.12.0) | +| [`microsoftSqlServer`](/orm/overview/databases/sql-server) | [2.10.0](https://github.com/prisma/prisma/releases/tag/2.10.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | +| [`namedConstraints`](/orm/prisma-schema/data-model/database-mapping#constraint-and-index-names) | [2.29.0](https://github.com/prisma/prisma/releases/tag/2.29.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | +| [`referentialActions`](/orm/prisma-schema/data-model/relations/referential-actions) | [2.26.0](https://github.com/prisma/prisma/releases/tag/2.26.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | +| [`orderByAggregateGroup`](/orm/prisma-client/queries/aggregation-grouping-summarizing#order-by-aggregate-group) | [2.21.0](https://github.com/prisma/prisma/releases/tag/2.21.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | +| [`orderByRelation`](/orm/prisma-client/queries/filtering-and-sorting#sort-by-relation) |
  • [2.16.0](https://github.com/prisma/prisma/releases/tag/2.16.0)
  • order by aggregates of relations in [2.19.0](https://github.com/prisma/prisma/releases/tag/2.19.0)
| [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | +| [`selectRelationCount`](/orm/prisma-client/queries/aggregation-grouping-summarizing#count-relations) | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | +| `napi` | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | [3.0.1](https://github.com/prisma/prisma/releases/tag/3.0.1) | +| [`groupBy`](/orm/reference/prisma-client-reference#groupby) | [2.14.0](https://github.com/prisma/prisma/releases/tag/2.14.0) | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | +| [`createMany`](/orm/reference/prisma-client-reference#createmany) | [2.16.0](https://github.com/prisma/prisma/releases/tag/2.16.0) | [2.20.0](https://github.com/prisma/prisma/releases/tag/2.20.0) | +| [`nativeTypes`](/orm/prisma-schema/data-model/models#native-types-mapping) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) | +| [`uncheckedScalarInputs`](/orm/prisma-client/queries/relation-queries#create-a-single-record-and-multiple-related-records) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | [2.15.0](https://github.com/prisma/prisma/releases/tag/2.15.0) | +| [`transactionApi`](/orm/prisma-client/queries/transactions#the-transaction-api) | [2.1.0](https://github.com/prisma/prisma/releases/tag/2.1.0) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | +| [`connectOrCreate`](/orm/reference/prisma-client-reference#connectorcreate) | [2.1.0](https://github.com/prisma/prisma/releases/tag/2.1.0) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) | +| [`atomicNumberOperations`](/orm/reference/prisma-client-reference#atomic-number-operations) | [2.6.0](https://github.com/prisma/prisma/releases/tag/2.6.0) | [2.10.0](https://github.com/prisma/prisma/releases/tag/2.10.0) | +| [`insensitiveFilters` (PostgreSQL)](/orm/prisma-client/queries/filtering-and-sorting#case-insensitive-filtering) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | [2.8.0](https://github.com/prisma/prisma/releases/tag/2.8.0) | +| [`middlewares`](/orm/prisma-client/client-extensions/middleware) | [2.3.0](https://github.com/prisma/prisma/releases/tag/2.3.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | +| [`aggregateApi`](/orm/prisma-client/queries/aggregation-grouping-summarizing#aggregate) | [2.2.0](https://github.com/prisma/prisma/releases/tag/2.2.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | +| [`distinct`](/orm/reference/prisma-client-reference#distinct) | [2.3.0](https://github.com/prisma/prisma/releases/tag/2.3.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | diff --git a/content/200-orm/800-more/100-under-the-hood/100-engines.mdx b/content/200-orm/800-more/100-under-the-hood/100-engines.mdx index de5d02ed2a..cbe7f24871 100644 --- a/content/200-orm/800-more/100-under-the-hood/100-engines.mdx +++ b/content/200-orm/800-more/100-under-the-hood/100-engines.mdx @@ -62,7 +62,7 @@ Add the environment variable to the [`.env` file](/orm/more/development-environm - + ``` PRISMA_QUERY_ENGINE_BINARY=custom/my-query-engine-unix @@ -86,7 +86,7 @@ Run the following command to set the environment variable globally (in this exam - + ```terminal export PRISMA_QUERY_ENGINE_BINARY=/custom/my-query-engine-unix @@ -116,7 +116,7 @@ The output shows that the query engine path comes from the `PRISMA_QUERY_ENGINE_ - + ```terminal highlight=2;normal Current platform : darwin Query Engine : query-engine d6ff7119649922b84e413b3b69660e2f49e2ddf3 (at /custom/my-query-engine-unix) diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/500-upgrading-to-prisma-6.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/500-upgrading-to-prisma-6.mdx new file mode 100644 index 0000000000..42e05f2b55 --- /dev/null +++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/500-upgrading-to-prisma-6.mdx @@ -0,0 +1,343 @@ +--- +title: 'Upgrade to Prisma ORM 6' +metaTitle: 'Upgrade to Prisma ORM 6' +metaDescription: 'Guides on how to upgrade to Prisma ORM 6' +tocDepth: 3 +toc: true +--- + +Prisma ORM v6 introduces a number of **breaking changes** when you upgrade from an earlier Prisma ORM version. This guide explains how this upgrade might affect your application and gives instructions on how to handle any changes. + +## Upgrade the `prisma` and `@prisma/client` packages to v6 + +To upgrade to Prisma ORM v6 from an earlier version, you need to update both the `prisma` and `@prisma/client` packages: + + + + + +```terminal +npm install @prisma/client@6 +npm install -D prisma@6 +``` + + + + + +```terminal +yarn up prisma@6 @prisma/client@6 +``` + + + + + +```terminal +pnpm upgrade prisma@6 @prisma/client@6 +``` + + + + + +```terminal +bun add @prisma/client@6 +bun add prisma@6 --dev +``` + + + + + +:::danger + +Before you upgrade, check each breaking change below to see how the upgrade might affect your application. + +::: + + +## Breaking changes + +This section gives an overview of breaking changes in Prisma ORM v6. + +### Minimum supported Node.js versions + +The new minimum supported Node.js version sfor Prisma ORM v6 are: + +- for Node.js 18 the minimum supported version is **18.18.0** +- for Node.js 20 the minimum supported version is **20.9.0** +- for Node.js 22 the minimum supported version is **22.11.0** + +There is _no_ official support for Node.js 16, 17, 19 and 21. + +### Minimum supported TypeScript version + +The new minimum supported TypeScript version for Prisma ORM v6 is: **5.1.0**. + +### Schema change for implicit m-n relations on PostgreSQL + +If you're using PostgreSQL and are defining [implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations) in your Prisma schema, Prisma ORM maintains the [relation table](/orm/prisma-schema/data-model/relations/many-to-many-relations#relation-tables) for you under the hood. This relation table has `A` and `B` columns to represent the tables of the models that are part of this relation. + + +Previous versions of Prisma ORM used to create a _unique index_ on these two columns. In Prisma v6, this unique index is changing to a _primary key_ in order to [simplify for the default replica identity behaviour](https://github.com/prisma/prisma/issues/25196). + +
+Expand for an example + +As an example, consider this relation table of an implicit m-n relation between `Post` and `Tag` models: + +```sql +-- CreateTable +CREATE TABLE "_PostToTag" ( + "A" INTEGER NOT NULL, + "B" INTEGER NOT NULL +); + +-- CreateIndex +-- highlight-next-line +CREATE UNIQUE INDEX "_PostToTag_AB_unique" ON "_PostToTag"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PostToTag_B_index" ON "_PostToTag"("B"); + +-- AddForeignKey +ALTER TABLE "_PostToTag" ADD CONSTRAINT "_PostToTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PostToTag" ADD CONSTRAINT "_PostToTag_B_fkey" FOREIGN KEY ("B") REFERENCES "Tag"("id") ON DELETE CASCADE ON UPDATE CASCADE; +``` + +In Prisma v6, the `UNIQUE INDEX` is changing into a `PRIMARY KEY`: + +```sql +-- CreateTable +CREATE TABLE "_PostToTag" ( + "A" INTEGER NOT NULL, + "B" INTEGER NOT NULL, + + -- highlight-next-line + CONSTRAINT "_PostToTag_AB_pkey" PRIMARY KEY ("A","B") +); + +-- CreateIndex +CREATE INDEX "_PostToTag_B_index" ON "_PostToTag"("B"); + +-- AddForeignKey +ALTER TABLE "_PostToTag" ADD CONSTRAINT "_PostToTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PostToTag" ADD CONSTRAINT "_PostToTag_B_fkey" FOREIGN KEY ("B") REFERENCES "Tag"("id") ON DELETE CASCADE ON UPDATE CASCADE; +``` + +
+ +If you're defining implicit m-n relations in your Prisma schema, **the next migration you'll create will contain `ALTER TABLE` statements for _all_ the relation tables** that belong to these relations. These will look similar to this: + +```sql +-- AlterTable +ALTER TABLE "_PostToTag" ADD CONSTRAINT "_PostToTag_AB_pkey" PRIMARY KEY ("A", "B"); + +-- DropIndex +DROP INDEX "_PostToTag_AB_unique"; +``` + +In order to isolate these schema changes (and not having them bundled with your next migration), **we recommend that you create a new migration _right after_ having upgraded to Prisma v6**: + +```terminal +npx prisma migrate dev --name upgrade-to-v6 +``` + +That way, you have a single, dedicated migration that takes care of this schema change and otherwise keeps your migration history clean. + +### Full-text search on PostgreSQL + +The `fullTextSearch` Preview feature is promoted to General Availability only for MySQL. This means that if you're using PostgreSQL and currently make use of this Preview feature, you now need to use the new `fullTextSearchPostgres` Preview feature: + +#### Before + +```prisma file=schema.prisma +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +generator client { + provider = "prisma-client-js" + // edit-next-line + previewFeatures = ["fullTextSearch"] +} +``` + +#### After + +```prisma file=schema.prisma +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +generator client { + provider = "prisma-client-js" + // edit-next-line + previewFeatures = ["fullTextSearchPostgres"] +} +``` + +### Usage of `Buffer` + +In an effort to improve compatibility between Prisma and new modern JavaScript runtimes, we're gradually moving away from Node.js-specific APIs in favor of standard JavaScript. + +Prisma v6 replaces the usage of [`Buffer`](https://nodejs.org/api/buffer.html) with [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) to represent fields of type `Bytes`. Make sure to replace all your occurences of the `Buffer` type with the new `Uint8Array`. + +#### Before + +```ts +import { PrismaClient } from '@prisma/client' + +async function main() { + const prisma = new PrismaClient() + await prisma.user.deleteMany() + + const bytesCreated = await prisma.user.create({ + data: { + bytes: Buffer.from([1, 2, 3, 4]), + }, + }) + // ^^^^^^^^^^^^^^^^^^^^^^^^^^ + // `bytesCreated` used to have type: { + // bytes: Buffer + // id: number + // } + + for (const bytesFound of await prisma.user.findMany()) { + bytesFound.bytes // Buffer [ 1, 2, 3, 4 ] + } +} + +main() +``` + +#### After + +```ts +import { PrismaClient } from '@prisma/client' + +async function main() { + const prisma = new PrismaClient() + await prisma.user.deleteMany() + + const bytesCreated = await prisma.user.create({ + data: { + bytes: Uint8Array.from([1, 2, 3, 4]), + }, + }) + // ^^^^^^^^^^^^^^^^^^^^^^^^^^ + // `bytesCreated` now has type: { + // bytes: Uint8Array + // id: number + // } + + for (const bytesFound of await prisma.user.findMany()) { + bytesFound.bytes // Uint8Array [ 1, 2, 3, 4 ] + } +} + +main() +``` + +### Removed `NotFoundError` + +In Prisma v6, we removed the `NotFoundError` in favor of `PrismaClientKnownRequestError` with error code [`P2025`](/orm/reference/error-reference#p2025) in [`findUniqueOrThrow()`](/orm/reference/prisma-client-reference#finduniqueorthrow) and [`findFirstOrThrow()`](/orm/reference/prisma-client-reference#findfirstorthrow). If you've relied on catching `NotFoundError` instances in your code, you need to adjust the code accordingly. + +#### Before + +```ts +import { PrismaClient, NotFoundError } from '@prisma/client'; + +// inside an `async` function +try { + const user = await prisma.user.findUniqueOrThrow({ + where: { id: 42 }, + }); + console.log(user); +} catch (error) { + // highlight-start + if (error instanceof NotFoundError) { + console.error("User not found!"); + } + // highlight-end + else { + console.error("Unexpected error:", error); + } +} +``` + +#### After + +```ts +import { PrismaClient, Prisma } from '@prisma/client'; + +// inside an `async` function +try { + const user = await prisma.user.findUniqueOrThrow({ + where: { id: 42 }, + }); + console.log(user); +} catch (error) { + // highlight-start + if ( + error instanceof Prisma.PrismaClientKnownRequestError && + error.code === 'P2025' // Specific code for "record not found" + ) { + console.error("User not found!"); + } + // highlight-end + else { + console.error("Unexpected error:", error); + } +} +``` + +### New keywords that can't be used as model names: `async`, `await`, `using` + +With this release, you can't use `async`, `await` and `using` as model names any more. + + +## Preview features promoted to General Availability + +In this release, we are promoting a number of [Preview](/orm/more/releases#preview) features to [General Availability](/orm/more/releases#generally-available-ga). + +### `fullTextIndex` + +If you use the [full-text index](/orm/prisma-schema/data-model/indexes#full-text-indexes-mysql-and-mongodb) feature in your app, you can now remove `fullTextIndex` from the `previewFeatures` in your Prisma schema: + +```prisma +generator client { + provider = "prisma-client-js" + // delete-next-line + previewFeatures = ["fullTextIndex"] +} +``` + +### `fullTextSearch` + +If you use the [full-text search](/orm/prisma-client/queries/full-text-search) feature with **MySQL** in your app, you can now remove `fullTextSearch` from the `previewFeatures` in your Prisma schema: + +```prisma +generator client { + provider = "prisma-client-js" + // delete-next-line + previewFeatures = ["fullTextSearch"] +} +``` + +If you are using it with **PostgreSQL**, you need to update the name of the feature flag to `fullTextSearchPostgres`: + +```prisma +generator client { + provider = "prisma-client-js" + // edit-next-line + previewFeatures = ["fullTextSearchPostgres"] +} +``` diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx index baeeb1e520..322e82a58c 100644 --- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx +++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx @@ -6,14 +6,10 @@ tocDepth: 3 toc: true --- - - Prisma ORM 5.0.0 introduces a number of changes, including the usage of our new JSON Protocol, [which make Prisma Client faster by default](https://www.prisma.io/blog/prisma-5-f66prwkjx72s). A full list of these changes can be found [in our release notes](https://github.com/prisma/prisma/releases/tag/5.0.0). This guide explains how upgrading might affect your application and gives instructions on how to handle breaking changes within Prisma ORM 5. - - ## Upgrade the `prisma` and `@prisma/client` packages to version 5 To upgrade to Prisma ORM 5 from an earlier version, you need to update both the `prisma` and `@prisma/client` packages. diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx index 35d372d05b..a207ab3508 100644 --- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx +++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx @@ -4,8 +4,6 @@ metaTitle: 'Upgrading versions (Guides)' metaDescription: 'Upgrading your project to the latest version of Prisma ORM.' --- - - To upgrade to the latest version of Prisma ORM: 1. Review [release notes](https://github.com/prisma/prisma/releases) on GitHub for breaking changes and new features. @@ -22,12 +20,11 @@ To upgrade to the latest version of Prisma ORM: ::: - - ## Common upgrade paths ### Prisma ORM 2 and onwards +- [Upgrade to Prisma ORM 6](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6) - [Upgrade to Prisma ORM 5](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-5) - [Upgrade to Prisma ORM 4](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-4) - [Upgrade to Prisma ORM 3](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-3) @@ -40,7 +37,7 @@ To upgrade to the latest version of Prisma ORM: ### `dev` distribution tag -The `dev` [Npm distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages/) points to the most recent development version of the package, which is published for each commit to the main branch of `prisma/prisma`. You can use the `dev` distribution tag to verify a fix or test a feature before it is officially released. +The `dev` [npm distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages/) points to the most recent development version of the package, which is published for each commit to the main branch of `prisma/prisma`. You can use the `dev` distribution tag to verify a fix or test a feature before it is officially released. To install the latest `dev` distribution tag: