diff --git a/cSpell.json b/cSpell.json index 47e69a8259..f63b541815 100644 --- a/cSpell.json +++ b/cSpell.json @@ -13,6 +13,7 @@ "datasource", "earlyaccess", "ecommerce", + "Fastify", "fulltext", "Hasura", "hotfix", diff --git a/config.ts b/config.ts index 76f0f92bc3..c02c94a7c5 100644 --- a/config.ts +++ b/config.ts @@ -20,32 +20,43 @@ const siteConfig = { to: '/getting-started', type: 'bucket', bucketName: '/100-getting-started', + hidden: false, }, { - text: 'Concepts', - to: '/concepts', + text: 'ORM', + to: '/orm', type: 'bucket', - bucketName: '/200-concepts', + bucketName: '/200-orm', + hidden: false, }, { - text: 'Guides', - to: '/guides', + text: 'Accelerate', + to: '/accelerate', type: 'bucket', - bucketName: '/300-guides', + bucketName: '/300-accelerate', + hidden: false, }, { - text: 'Reference', - to: '/reference', + text: 'Pulse', + to: '/pulse', type: 'bucket', - bucketName: '/400-reference', + bucketName: '/400-pulse', + hidden: false, }, { - text: 'Prisma Data Platform', - to: '/data-platform', + text: 'Platform', + to: '/platform', type: 'bucket', - bucketName: '/800-data-platform', + bucketName: '/500-platform', + hidden: false, + }, + { + text: 'About', + to: '/about', + type: 'bucket', + bucketName: '/600-about', + hidden: true, }, - { text: 'About', to: '/about', type: 'bucket', bucketName: '/600-about' }, ], search: { indexName: process.env.GATSBY_ALGOLIA_INDEX_NAME, @@ -101,11 +112,11 @@ const siteConfig = { 'An ecosystem of tools empowering teams to build data-heavy, global-first applications.', links: [ { - url: 'data-platform/accelerate', + url: 'accelerate', title: 'Prisma Accelerate', }, { - url: 'data-platform/pulse', + url: 'pulse', title: 'Prisma Pulse', }, ], @@ -115,39 +126,39 @@ const siteConfig = { { title: `What is Prisma`, description: 'An overview of what Prisma ORM is and how it works.', - url: 'concepts/overview/what-is-prisma', + url: 'orm/overview/introduction/what-is-prisma', icon: 'fa-regular fa-question', }, { title: `CRUD`, description: 'How to perform CRUD operations with your generated Prisma Client API. ', - url: 'concepts/components/prisma-client/crud', + url: 'orm/prisma-client/queries/crud', icon: 'fa-solid fa-arrow-right-arrow-left', }, { title: `Prisma in your stack`, description: 'Use Prisma to build a GraphQL or REST API, or as part of a fullstack application.', - url: 'concepts/overview/prisma-in-your-stack', + url: 'orm/overview/prisma-in-your-stack', icon: 'fa-solid fa-server', }, { title: `Preview features`, description: 'Available preview features and how to enable them.', - url: 'concepts/components/preview-features', + url: 'orm/reference/preview-features', icon: 'fa-solid fa-eye', }, { title: `Adopting Prisma`, description: 'Migrate to Prisma from other ORMs.', - url: 'guides/migrate-to-prisma', + url: 'orm/more/migrating-to-prisma', icon: 'fa-solid fa-download', }, { title: `Deployment guides`, description: 'Deploy Node.js applications with Prisma Client to platforms like Vercel, AWS Lambda, Netlify and Heroku.', - url: 'guides/deployment', + url: 'orm/prisma-client/deployment', icon: 'fa-solid fa-book', }, ], @@ -182,51 +193,51 @@ const siteConfig = { CardLinks: { components: [ { - url: 'concepts/components/prisma-schema', + url: 'orm/prisma-schema', title: 'Prisma Schema', }, { - url: 'concepts/components/prisma-cli', + url: 'orm/tools/prisma-cli', title: 'Prisma CLI', }, { - url: 'concepts/components/prisma-client', + url: 'orm/prisma-client', title: 'Prisma Client', }, { - url: 'concepts/components/prisma-studio', + url: 'orm/tools/prisma-studio', title: 'Prisma Studio', }, { - url: 'concepts/components/prisma-migrate', + url: 'orm/prisma-migrate', title: 'Prisma Migrate', }, ], reference: [ { - url: 'reference/api-reference/prisma-client-reference', + url: 'orm/reference/prisma-client-reference', title: 'Prisma Client API reference', }, { - url: 'reference/api-reference/prisma-schema-reference', + url: 'orm/reference/prisma-schema-reference', title: 'Prisma schema reference', }, { - url: 'reference/api-reference/error-reference', + url: 'orm/reference/error-reference', title: 'Error message reference', }, { - url: 'reference/api-reference/command-reference', + url: 'orm/reference/prisma-cli-reference', title: 'Prisma CLI reference', }, ], }, }, siteMetadata: { - title: 'Prisma Documentation | Concepts, Guides, and Reference', + title: 'Prisma Documentation | ORM, Accelerate, Pulse & More', description: "Get started with Prisma in the official documentation, and learn more about all Prisma's features with reference documentation, guides, and more.", - keywords: 'Docs, prisma, 2.0', + keywords: 'Docs, Prisma, ORM', docsLocation: 'https://github.com/prisma/docs/tree/main/content', twitter: { site: '@prisma', diff --git a/content/100-getting-started/01-quickstart.mdx b/content/100-getting-started/01-quickstart.mdx index d263f9de57..440faaa0b3 100644 --- a/content/100-getting-started/01-quickstart.mdx +++ b/content/100-getting-started/01-quickstart.mdx @@ -19,7 +19,7 @@ If you want to use Prisma with your own PostgreSQL, MySQL, MongoDB or any other ## Prerequisites -You need Node.js v16.13.0 or higher for this guide (learn more about [system requirements](/reference/system-requirements)). +You need Node.js v16.13.0 or higher for this guide (learn more about [system requirements](/orm/reference/system-requirements)). ## 1. Create TypeScript project and set up Prisma @@ -41,7 +41,7 @@ This creates a `package.json` with an initial setup for your TypeScript app. -See [installation instructions](/reference/api-reference/command-reference#installation) to learn how to install Prisma using a different package manager. +See [installation instructions](/orm/tools/prisma-cli#installation) to learn how to install Prisma using a different package manager. @@ -108,7 +108,6 @@ This command did three things: 2. It executed the SQL migration file against the database. 3. It ran `prisma generate` under the hood (which installed the `@prisma/client` package and generated a tailored Prisma Client API based on your models). - Because the SQLite database file didn't exist before, the command also created it inside the `prisma` directory with the name `dev.db` as defined via the environment variable in the `.env` file. Congratulations, you now have your database and tables ready. Let's go and learn how you can send some queries to read and write data! @@ -256,7 +255,7 @@ Notice how the single `User` object is now enclosed with square brackets in the ### 4.3. Explore relation queries with Prisma -One of the main features of Prisma Client is the ease of working with [relations](/concepts/components/prisma-schema/relations). In this section, you'll learn how to create a `User` and a `Post` record in a nested write query. Afterwards, you'll see how you can retrieve the relation from the database using the `include` option. +One of the main features of Prisma Client is the ease of working with [relations](/orm/prisma-schema/data-model/relations). In this section, you'll learn how to create a `User` and a `Post` record in a nested write query. Afterwards, you'll see how you can retrieve the relation from the database using the `include` option. First, adjust your script to include the nested query: diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx index b7684611e2..21ddb6ed77 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx @@ -9,7 +9,7 @@ toc: false ## Connect your database -To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/reference/database-reference/connection-urls): +To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/orm/reference/connection-urls): @@ -20,7 +20,7 @@ datasource db { } ``` -In this case, the `url` is [set via an environment variable](/guides/development-environment/environment-variables) which is defined in `.env`: +In this case, the `url` is [set via an environment variable](/orm/more/development-environment/environment-variables) which is defined in `.env`: ```bash file=.env DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public" @@ -34,7 +34,7 @@ We recommend adding `.env` to your `.gitignore` file to prevent committing your You now need to adjust the connection URL to point to your own database. -The [format of the connection URL](/reference/database-reference/connection-urls) for your database depends on the database you use. For PostgreSQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database depends on the database you use. For PostgreSQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA @@ -51,7 +51,7 @@ Here's a short explanation of each component: If you're unsure what to provide for the `schema` parameter for a PostgreSQL connection URL, you can probably omit it. In that case, the default schema name `public` will be used. -As an example, for a PostgreSQL database hosted on Heroku, the [connection URL](/reference/database-reference/connection-urls) might look similar to this: +As an example, for a PostgreSQL database hosted on Heroku, the [connection URL](/orm/reference/connection-urls) might look similar to this: ```bash file=.env DATABASE_URL="postgresql://opnmyfngbknppm:XXX@ec2-46-137-91-216.eu-west-1.compute.amazonaws.com:5432/d50rgmkqi2ipus?schema=hello-prisma" @@ -83,7 +83,7 @@ datasource db { } ``` -In this case, the `url` is [set via an environment variable](/concepts/components/prisma-schema#accessing-environment-variables-from-the-schema) which is defined in `.env`: +In this case, the `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) which is defined in `.env`: ```bash file=.env DATABASE_URL="mysql://johndoe:randompassword@localhost:3306/mydb" @@ -97,7 +97,7 @@ We recommend adding `.env` to your `.gitignore` file to prevent committing your You now need to adjust the connection URL to point to your own database. -The [format of the connection URL](/reference/database-reference/connection-urls) for your database typically depends on the database you use. For MySQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database typically depends on the database you use. For MySQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines mysql://USER:PASSWORD@HOST:PORT/DATABASE @@ -110,7 +110,7 @@ Here's a short explanation of each component: - `PORT`: The port where your database server is running (typically `3306` for MySQL) - `DATABASE`: The name of the [database](https://dev.mysql.com/doc/refman/8.0/en/creating-database.html) -As an example, for a MySQL database hosted on AWS RDS, the [connection URL](/reference/database-reference/connection-urls) might look similar to this: +As an example, for a MySQL database hosted on AWS RDS, the [connection URL](/orm/reference/connection-urls) might look similar to this: ```bash file=.env DATABASE_URL="mysql://johndoe:XXX@mysql–instance1.123456789012.us-east-1.rds.amazonaws.com:3306/mydb" @@ -142,7 +142,7 @@ datasource db { } ``` -You will also need to [set the relation mode type to `prisma`](/concepts/components/prisma-schema/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) in the `datasource` block: +You will also need to [set the relation mode type to `prisma`](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) in the `datasource` block: ```prisma file=schema.prisma highlight=4;add datasource db { @@ -152,7 +152,7 @@ datasource db { } ``` -The `url` is [set via an environment variable](/concepts/components/prisma-schema#accessing-environment-variables-from-the-schema) which is defined in `.env`: +The `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) which is defined in `.env`: ```bash file=.env DATABASE_URL="mysql://janedoe:mypassword@server.us-east-2.psdb.cloud/mydb?sslaccept=strict" @@ -160,7 +160,7 @@ DATABASE_URL="mysql://janedoe:mypassword@server.us-east-2.psdb.cloud/mydb?sslacc You now need to adjust the connection URL to point to your own database. -The [format of the connection URL](/reference/database-reference/connection-urls) for your database typically depends on the database you use. PlanetScale uses the MySQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database typically depends on the database you use. PlanetScale uses the MySQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines mysql://USER:PASSWORD@HOST:PORT/DATABASE @@ -173,7 +173,7 @@ Here's a short explanation of each component: - `PORT`: The port where your database server is running (typically `3306` for MySQL) - `DATABASE`: The name of the [database](https://dev.mysql.com/doc/refman/8.0/en/creating-database.html) -For a database hosted with PlanetScale, the [connection URL](/reference/database-reference/connection-urls) looks similar to this: +For a database hosted with PlanetScale, the [connection URL](/orm/reference/connection-urls) looks similar to this: ```bash file=.env DATABASE_URL="mysql://myusername:mypassword@server.us-east-2.psdb.cloud/mydb?sslaccept=strict" @@ -216,9 +216,9 @@ datasource db { } ``` -In this case, the `url` is [set via an environment variable](/concepts/components/prisma-schema#accessing-environment-variables-from-the-schema) which is defined in `.env`: +In this case, the `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) which is defined in `.env`: -The following example connection URL [uses SQL authentication](/concepts/database-connectors/sql-server), but there are [other ways to format your connection URL](/concepts/database-connectors/sql-server) +The following example connection URL [uses SQL authentication](/orm/overview/databases/sql-server), but there are [other ways to format your connection URL](/orm/overview/databases/sql-server) ```bash file=.env DATABASE_URL="sqlserver://localhost:1433;database=mydb;user=sa;password=r@ndomP@$$w0rd;trustServerCertificate=true" @@ -230,7 +230,7 @@ We recommend adding `.env` to your `.gitignore` file to prevent committing your -Adjust the connection URL to match your setup - see [Microsoft SQL Server connection URL](/concepts/database-connectors/sql-server) for more information. +Adjust the connection URL to match your setup - see [Microsoft SQL Server connection URL](/orm/overview/databases/sql-server) for more information. > Make sure TCP/IP connections are enabled via [SQL Server Configuration Manager](https://docs.microsoft.com/en-us/sql/relational-databases/sql-server-configuration-manager) to avoid `No connection could be made because the target machine actively refused it. (os error 10061)` @@ -254,9 +254,9 @@ datasource db { } ``` -The `url` is [set via an environment variable](/guides/development-environment/environment-variables) which is defined in `.env`. You now need to adjust the connection URL to point to your own database. +The `url` is [set via an environment variable](/orm/more/development-environment/environment-variables) which is defined in `.env`. You now need to adjust the connection URL to point to your own database. -The [format of the connection URL](/reference/database-reference/connection-urls) for your database depends on the database you use. CockroachDB uses the PostgreSQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database depends on the database you use. CockroachDB uses the PostgreSQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines postgresql://USER:PASSWORD@HOST:PORT/DATABASE?PARAMETERS @@ -270,7 +270,7 @@ Here's a short explanation of each component: - `DATABASE`: The name of the database - `PARAMETERS`: Any additional connection parameters. See the CockroachDB documentation [here](https://www.cockroachlabs.com/docs/stable/connection-parameters.html#additional-connection-parameters). -For a [CockroachDB Serverless](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart.html) or [Cockroach Dedicated](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart-trial-cluster) database hosted on [CockroachDB Cloud](https://www.cockroachlabs.com/get-started-cockroachdb/), the [connection URL](/reference/database-reference/connection-urls) looks similar to this: +For a [CockroachDB Serverless](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart.html) or [Cockroach Dedicated](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart-trial-cluster) database hosted on [CockroachDB Cloud](https://www.cockroachlabs.com/get-started-cockroachdb/), the [connection URL](/orm/reference/connection-urls) looks similar to this: ```bash file=.env DATABASE_URL="postgresql://:@..cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=$HOME/.postgresql/root.crt&options=--" @@ -278,7 +278,7 @@ DATABASE_URL="postgresql://:@..cockroa To find your connection string on CockroachDB Cloud, click the 'Connect' button on the overview page for your database cluster, and select the 'Connection string' tab. -For a [CockroachDB database hosted locally](https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html), the [connection URL](/reference/database-reference/connection-urls) looks similar to this: +For a [CockroachDB database hosted locally](https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html), the [connection URL](/orm/reference/connection-urls) looks similar to this: ```bash file=.env DATABASE_URL="postgresql://root@localhost:26257?sslmode=disable" diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx index 5161bd8d5c..734bfeee23 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx @@ -11,7 +11,7 @@ toc: false -In this guide, you'll use [Prisma Migrate](/concepts/components/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your [Prisma schema](/concepts/components/prisma-schema) in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your [Prisma schema](/orm/prisma-schema) in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -60,7 +60,7 @@ Great, you now created three tables in your database with Prisma Migrate 🚀 -In this guide, you'll use [Prisma Migrate](/concepts/components/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -109,7 +109,7 @@ Great, you now created three tables in your database with Prisma Migrate 🚀 -In this guide, you'll use Prisma's [`db push` command](/concepts/components/prisma-migrate/db-push) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use Prisma's [`db push` command](/orm/prisma-migrate/workflows/prototyping-your-schema) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -157,7 +157,7 @@ Great, you now created three tables in your database with Prisma's `db push` com -In this guide, you'll use [Prisma Migrate](/concepts/components/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -533,7 +533,7 @@ END CATCH -In this guide, you'll use [Prisma Migrate](/concepts/components/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/250-querying-the-database.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/250-querying-the-database.mdx index e730cd26f8..5b85245b3e 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/250-querying-the-database.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/250-querying-the-database.mdx @@ -9,7 +9,7 @@ toc: false ## Write your first query with Prisma Client -Now that you have generated [Prisma Client](/concepts/components/prisma-client), you can start writing queries to read and write data in your database. For the purpose of this guide, you'll use a plain Node.js script to explore some basic features of Prisma Client. +Now that you have generated [Prisma Client](/orm/prisma-client), you can start writing queries to read and write data in your database. For the purpose of this guide, you'll use a plain Node.js script to explore some basic features of Prisma Client. @@ -185,9 +185,9 @@ async function main() { -This code creates a new `User` record together with new `Post` and `Profile` records using a [nested write](/concepts/components/prisma-client/relation-queries#nested-writes) query. The `User` record is connected to the two other ones via the `Post.author` ↔ `User.posts` and `Profile.user` ↔ `User.profile` [relation fields](/concepts/components/prisma-schema/relations#relation-fields) respectively. +This code creates a new `User` record together with new `Post` and `Profile` records using a [nested write](/orm/prisma-client/queries/relation-queries#nested-writes) query. The `User` record is connected to the two other ones via the `Post.author` ↔ `User.posts` and `Profile.user` ↔ `User.profile` [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) respectively. -Notice that you're passing the [`include`](/concepts/components/prisma-client/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` and `profile` relations on the returned `User` objects. +Notice that you're passing the [`include`](/orm/prisma-client/queries/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` and `profile` relations on the returned `User` objects. Run the code with this command: @@ -237,7 +237,7 @@ The output should look similar to this: -Also note that `allUsers` is _statically typed_ thanks to [Prisma Client's generated types](/concepts/components/prisma-client/advanced-type-safety/operating-against-partial-structures-of-model-types). You can observe the type by hovering over the `allUsers` variable in your editor. It should be typed as follows: +Also note that `allUsers` is _statically typed_ thanks to [Prisma Client's generated types](/orm/prisma-client/type-safety/operating-against-partial-structures-of-model-types). You can observe the type by hovering over the `allUsers` variable in your editor. It should be typed as follows: ```ts no-lines const allUsers: (User & { diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx index 6c4834f7c9..dc0d133e74 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx @@ -9,11 +9,11 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/concepts/overview/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. ### Continue exploring the Prisma Client API -You can send a variety of queries with the Prisma Client API. Check out the [API reference](/concepts/components/prisma-client) and use your existing database setup from this guide to try them out. +You can send a variety of queries with the Prisma Client API. Check out the [API reference](/orm/prisma-client) and use your existing database setup from this guide to try them out. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx index 1e80f02a90..c8cb90bda0 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['postgresql', 'mysql', 'sqlserver', 'planetscale', 'cockroachdb'] -Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/concepts/components/prisma-cli), [Prisma Client](/concepts/components/prisma-client), and [Prisma Migrate](/concepts/components/prisma-migrate). +Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Migrate](/orm/prisma-migrate). @@ -56,14 +56,14 @@ This tutorial will also assume that you can push to the `main` branch of your da - [Node.js](https://nodejs.org/en/) installed on your machine - A [Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/?view=sql-server-ver15) database - - [Microsoft SQL Server on Linux for Docker](/concepts/database-connectors/sql-server/sql-server-docker) - - [Microsoft SQL Server on Windows (local)](/concepts/database-connectors/sql-server/sql-server-local) + - [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) -> See [System requirements](/reference/system-requirements) for exact version requirements. +> See [System requirements](/orm/reference/system-requirements) for exact version requirements. -Make sure you have your database [connection URL](/reference/database-reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). ## Create project setup @@ -108,7 +108,7 @@ This creates a `package.json` with an initial setup for a Node.js app. -See [installation instructions](/reference/api-reference/command-reference#installation) to learn how to install Prisma using a different package manager. +See [installation instructions](/orm/tools/prisma-cli#installation) to learn how to install Prisma using a different package manager. @@ -118,7 +118,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`: npx prisma ``` -Next, set up your Prisma project by creating your [Prisma schema](/concepts/components/prisma-schema) file with the following command: +Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file with the following command: ```terminal copy npx prisma init @@ -127,7 +127,7 @@ npx prisma init This command does two things: - creates a new directory called `prisma` that contains a file called `schema.prisma`, which contains the Prisma schema with your database connection variable and schema models -- creates the [`.env` file](/guides/development-environment/environment-variables#using-env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) +- creates the [`.env` file](/orm/more/development-environment/environment-variables/env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/100-connect-your-database.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/100-connect-your-database.mdx index db8ef8f9da..9edea9c598 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/100-connect-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/100-connect-your-database.mdx @@ -9,7 +9,7 @@ toc: false ## Connect your database -To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/reference/database-reference/connection-urls): +To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/orm/reference/connection-urls): ```prisma file=prisma/schema.prisma datasource db { @@ -18,7 +18,7 @@ datasource db { } ``` -In this case, the `url` is [set via an environment variable](/guides/development-environment/environment-variables) which is defined in `.env` (the example uses a [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) URL): +In this case, the `url` is [set via an environment variable](/orm/more/development-environment/environment-variables) which is defined in `.env` (the example uses a [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) URL): ```bash file=.env DATABASE_URL="mongodb+srv://test:test@cluster0.ns1yp.mongodb.net/myFirstDatabase" @@ -26,7 +26,7 @@ DATABASE_URL="mongodb+srv://test:test@cluster0.ns1yp.mongodb.net/myFirstDatabase You now need to adjust the connection URL to point to your own database. -The [format of the connection URL](/reference/database-reference/connection-urls) for your database depends on the database you use. For MongoDB, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database depends on the database you use. For MongoDB, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines mongodb://USERNAME:PASSWORD@HOST:PORT/DATABASE diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx index 3f8bafbc50..ece8f719b7 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/125-creating-the-prisma-schema.mdx @@ -59,7 +59,7 @@ There are also a number of subtle differences in how the schema is setup when co For example, the underlying `ID` field name is always `_id` and must be mapped with `@map("_id")`. -For more information check out the [MongoDB schema reference](/reference/api-reference/prisma-schema-reference#mongodb-2). +For more information check out the [MongoDB schema reference](/orm/reference/prisma-schema-reference#mongodb-2). diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx index b29fcd4c29..d650cc2032 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/250-querying-the-database.mdx @@ -185,9 +185,9 @@ async function main() { -This code creates a new `User` record together with a new `Post` using a [nested write](/concepts/components/prisma-client/relation-queries#nested-writes) query. The `User` record is connected to the other one via the `Post.author` ↔ `User.posts` [relation fields](/concepts/components/prisma-schema/relations#relation-fields) respectively. +This code creates a new `User` record together with a new `Post` using a [nested write](/orm/prisma-client/queries/relation-queries#nested-writes) query. The `User` record is connected to the other one via the `Post.author` ↔ `User.posts` [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) respectively. -Notice that you're passing the [`include`](/concepts/components/prisma-client/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` relations on the returned `User` objects. +Notice that you're passing the [`include`](/orm/prisma-client/queries/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` relations on the returned `User` objects. Run the code with this command: @@ -231,7 +231,7 @@ The output should look similar to this: -Also note that `allUsers` is _statically typed_ thanks to [Prisma Client's generated types](/concepts/components/prisma-client/advanced-type-safety/operating-against-partial-structures-of-model-types). You can observe the type by hovering over the `allUsers` variable in your editor. It should be typed as follows: +Also note that `allUsers` is _statically typed_ thanks to [Prisma Client's generated types](/orm/prisma-client/type-safety/operating-against-partial-structures-of-model-types). You can observe the type by hovering over the `allUsers` variable in your editor. It should be typed as follows: ```ts no-lines const allUsers: (User & { diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx index 0333f41319..628f0abc58 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx @@ -9,11 +9,11 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/concepts/overview/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. ### Continue exploring the Prisma Client API -You can send a variety of queries with the Prisma Client API. Check out the [API reference](/concepts/components/prisma-client) and use your existing database setup from this guide to try them out. +You can send a variety of queries with the Prisma Client API. Check out the [API reference](/orm/prisma-client) and use your existing database setup from this guide to try them out. diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx index 7588a6f41c..d85b9fab97 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['mongodb'] -Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma to your MongoDB database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/concepts/components/prisma-cli) and [Prisma Client](/concepts/components/prisma-client). +Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma to your MongoDB database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli) and [Prisma Client](/orm/prisma-client). @@ -27,9 +27,9 @@ In order to successfully complete this guide, you need: -Make sure you have your database [connection URL](/reference/database-reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). -> See [System requirements](/reference/system-requirements) for exact version requirements. +> See [System requirements](/orm/reference/system-requirements) for exact version requirements. ## Create project setup @@ -78,7 +78,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`: npx prisma ``` -Next, set up your Prisma project by creating your [Prisma schema](/concepts/components/prisma-schema) file with the following command: +Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file with the following command: ```terminal copy npx prisma init @@ -87,7 +87,7 @@ npx prisma init This command does two things: - creates a new directory called `prisma` that contains a file called `schema.prisma`, which contains the Prisma schema with your database connection variable and schema models -- creates the [`.env` file](/guides/development-environment/environment-variables#using-env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) +- creates the [`.env` file](/orm/more/development-environment/environment-variables/env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/index.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/index.mdx index 8b9e74adf7..491ba8b0b5 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/index.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/index.mdx @@ -7,7 +7,7 @@ toc: false -Start a fresh project from scratch with the following tutorials as they introduce you to the [Prisma CLI](/concepts/components/prisma-cli), [Prisma Client](/concepts/components/prisma-client), and [Prisma Migrate](/concepts/components/prisma-migrate). +Start a fresh project from scratch with the following tutorials as they introduce you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Migrate](/orm/prisma-migrate). diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx index 07f99cbda7..d1079ba7ce 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx @@ -9,7 +9,7 @@ toc: false ## Connecting your database -To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/reference/database-reference/connection-urls): +To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/orm/reference/connection-urls): @@ -20,7 +20,7 @@ datasource db { } ``` -In this case, the `url` is [set via an environment variable](/guides/development-environment/environment-variables) which is defined in `.env`: +In this case, the `url` is [set via an environment variable](/orm/more/development-environment/environment-variables) which is defined in `.env`: ```bash file=.env DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public" @@ -30,7 +30,7 @@ You now need to adjust the connection URL to point to your own database.

Connection URL

-The [format of the connection URL](/reference/database-reference/connection-urls) for your database depends on the database you use. For PostgreSQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database depends on the database you use. For PostgreSQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA @@ -72,7 +72,7 @@ datasource db { } ``` -In this case, the `url` is [set via an environment variable](/concepts/components/prisma-schema#accessing-environment-variables-from-the-schema) which is defined in `.env`: +In this case, the `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) which is defined in `.env`: ```bash file=.env DATABASE_URL="mysql://johndoe:randompassword@localhost:3306/mydb" @@ -82,7 +82,7 @@ You now need to adjust the connection URL to point to your own database.

Connection URL

-The [format of the connection URL](/reference/database-reference/connection-urls) for your database typically depends on the database you use. For MySQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database typically depends on the database you use. For MySQL, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines mysql://USER:PASSWORD@HOST:PORT/DATABASE @@ -95,7 +95,7 @@ Here's a short explanation of each component: - `PORT`: The port where your database server is running (typically `3306` for MySQL) - `DATABASE`: The name of the [database](https://dev.mysql.com/doc/refman/8.0/en/creating-database.html) -As an example, for a MySQL database hosted on AWS RDS, the [connection URL](/reference/database-reference/connection-urls) might look similar to this: +As an example, for a MySQL database hosted on AWS RDS, the [connection URL](/orm/reference/connection-urls) might look similar to this: ```bash file=.env DATABASE_URL="mysql://johndoe:XXX@mysql–instance1.123456789012.us-east-1.rds.amazonaws.com:3306/mydb" @@ -127,7 +127,7 @@ datasource db { } ``` -You will also need to [set the relation mode type to `prisma`](/concepts/components/prisma-schema/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) in the `datasource` block: +You will also need to [set the relation mode type to `prisma`](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) in the `datasource` block: ```prisma file=schema.prisma highlight=4;add datasource db { @@ -137,7 +137,7 @@ datasource db { } ``` -The `url` is [set via an environment variable](/concepts/components/prisma-schema#accessing-environment-variables-from-the-schema) which is defined in `.env`: +The `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) which is defined in `.env`: ```bash file=.env DATABASE_URL="mysql://janedoe:mypassword@server.us-east-2.psdb.cloud/mydb?sslaccept=strict" @@ -147,7 +147,7 @@ You now need to adjust the connection URL to point to your own database.

Connection URL

-The [format of the connection URL](/reference/database-reference/connection-urls) for your database typically depends on the database you use. PlanetScale uses the MySQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database typically depends on the database you use. PlanetScale uses the MySQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines mysql://USER:PASSWORD@HOST:PORT/DATABASE @@ -160,7 +160,7 @@ Here's a short explanation of each component: - `PORT`: The port where your database server is running (typically `3306` for MySQL) - `DATABASE`: The name of the [database](https://dev.mysql.com/doc/refman/8.0/en/creating-database.html) -For a database hosted with PlanetScale, the [connection URL](/reference/database-reference/connection-urls) looks similar to this: +For a database hosted with PlanetScale, the [connection URL](/orm/reference/connection-urls) looks similar to this: ```bash file=.env DATABASE_URL="mysql://myusername:mypassword@server.us-east-2.psdb.cloud/mydb?sslaccept=strict" @@ -197,13 +197,13 @@ datasource db { } ``` -The `url` is [set via an environment variable](/concepts/components/prisma-schema#accessing-environment-variables-from-the-schema), the following example connection URL [uses SQL authentication](/concepts/database-connectors/sql-server), but there are [other ways to format your connection URL](/concepts/database-connectors/sql-server) +The `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema), the following example connection URL [uses SQL authentication](/orm/overview/databases/sql-server), but there are [other ways to format your connection URL](/orm/overview/databases/sql-server) ```bash file=.env DATABASE_URL="sqlserver://localhost:1433;database=mydb;user=sa;password=r@ndomP@$$w0rd;trustServerCertificate=true" ``` -Adjust the connection URL to match your setup - see [Microsoft SQL Server connection URL](/concepts/database-connectors/sql-server) for more information. +Adjust the connection URL to match your setup - see [Microsoft SQL Server connection URL](/orm/overview/databases/sql-server) for more information. > Make sure TCP/IP connections are enabled via [SQL Server Configuration Manager](https://docs.microsoft.com/en-us/sql/relational-databases/sql-server-configuration-manager) to avoid `No connection could be made because the target machine actively refused it. (os error 10061)` @@ -227,11 +227,11 @@ datasource db { } ``` -The `url` is [set via an environment variable](/guides/development-environment/environment-variables) which is defined in `.env`. You now need to adjust the connection URL to point to your own database. +The `url` is [set via an environment variable](/orm/more/development-environment/environment-variables) which is defined in `.env`. You now need to adjust the connection URL to point to your own database.

Connection URL

-The [format of the connection URL](/reference/database-reference/connection-urls) for your database depends on the database you use. CockroachDB uses the PostgreSQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database depends on the database you use. CockroachDB uses the PostgreSQL connection URL format, which has the following structure (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines postgresql://USER:PASSWORD@HOST:PORT/DATABASE?PARAMETERS @@ -245,7 +245,7 @@ Here's a short explanation of each component: - `DATABASE`: The name of the database - `PARAMETERS`: Any additional connection parameters. See the CockroachDB documentation [here](https://www.cockroachlabs.com/docs/stable/connection-parameters.html#additional-connection-parameters). -For a [CockroachDB Serverless](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart.html) or [Cockroach Dedicated](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart-trial-cluster) database hosted on [CockroachDB Cloud](https://www.cockroachlabs.com/get-started-cockroachdb/), the [connection URL](/reference/database-reference/connection-urls) looks similar to this: +For a [CockroachDB Serverless](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart.html) or [Cockroach Dedicated](https://www.cockroachlabs.com/docs/cockroachcloud/quickstart-trial-cluster) database hosted on [CockroachDB Cloud](https://www.cockroachlabs.com/get-started-cockroachdb/), the [connection URL](/orm/reference/connection-urls) looks similar to this: ```bash file=.env DATABASE_URL="postgresql://:@..cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=$HOME/.postgresql/root.crt&options=--" @@ -253,7 +253,7 @@ DATABASE_URL="postgresql://:@..cockroa To find your connection string on CockroachDB Cloud, click the 'Connect' button on the overview page for your database cluster, and select the 'Connection string' tab. -For a [CockroachDB database hosted locally](https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html), the [connection URL](/reference/database-reference/connection-urls) looks similar to this: +For a [CockroachDB database hosted locally](https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html), the [connection URL](/orm/reference/connection-urls) looks similar to this: ```bash file=.env DATABASE_URL="postgresql://root@localhost:26257?sslmode=disable" diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx index 9f20a764f0..860789a46b 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx @@ -341,7 +341,7 @@ CREATE TABLE "Profile" ( -As a next step, you will introspect your database. The result of the introspection will be a [data model](/concepts/components/prisma-schema/data-model) inside your Prisma schema. +As a next step, you will introspect your database. The result of the introspection will be a [data model](/orm/prisma-schema/data-model/models) inside your Prisma schema. Run the following command to introspect your database: @@ -388,13 +388,13 @@ Prisma's data model is a declarative representation of your database schema and Right now, there's a few minor "issues" with the data model: -- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. -- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. -- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/concepts/components/prisma-schema/data-model#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. +- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. +- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. +- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/orm/prisma-schema/data-model/models#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. -These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names). +These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names). -Because [relation fields](/concepts/components/prisma-schema/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: +Because [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: ```prisma file=prisma/schema.prisma highlight=8,15,22,23;edit model Post { @@ -423,7 +423,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names @@ -451,7 +451,7 @@ const user = await prisma.my_user.create({ }) ``` -If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/concepts/components/prisma-schema/data-model#mapping-model-names-to-tables-or-collections): +If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/orm/prisma-schema/data-model/models#mapping-model-names-to-tables-or-collections): ```prisma no-lines model MyUser { @@ -474,7 +474,7 @@ const user = await prisma.myUser.create({ }) ``` -Learn more about this on the [Configuring your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names) page. +Learn more about this on the [Configuring your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) page.
@@ -482,7 +482,7 @@ Learn more about this on the [Configuring your Prisma Client API](/concepts/comp -As a next step, you will introspect your database. The result of the introspection will be a [data model](/concepts/components/prisma-schema/data-model) inside your Prisma schema. +As a next step, you will introspect your database. The result of the introspection will be a [data model](/orm/prisma-schema/data-model/models) inside your Prisma schema. Run the following command to introspect your database: @@ -529,7 +529,7 @@ model User { -Refer to the [Prisma schema reference](/reference/api-reference/prisma-schema-reference) for detailed information about the schema definition. +Refer to the [Prisma schema reference](/orm/reference/prisma-schema-reference) for detailed information about the schema definition. @@ -537,13 +537,13 @@ Prisma's data model is a declarative representation of your database schema and Right now, there's a few minor "issues" with the data model: -- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. -- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. -- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/concepts/components/prisma-schema/data-model#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. +- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. +- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. +- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/orm/prisma-schema/data-model/models#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. -These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names). +These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names). -Because [relation fields](/concepts/components/prisma-schema/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: +Because [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: ```prisma file=prisma/schema.prisma highlight=8,17,24,25;edit model Post { @@ -574,7 +574,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. Sometimes though, you may want to make additional changes to the names of the columns and tables that are exposed in the Prisma Client API. A common example is to translate _snake_case_ notation which is often used in database schemas into _PascalCase_ and _camelCase_ notations which feel more natural for JavaScript/TypeScript developers. @@ -599,7 +599,7 @@ const user = await prisma.my_user.create({ }) ``` -If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/concepts/components/prisma-schema/data-model#mapping-model-names-to-tables-or-collections): +If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/orm/prisma-schema/data-model/models#mapping-model-names-to-tables-or-collections): ```prisma no-lines model MyUser { @@ -622,13 +622,13 @@ const user = await prisma.myUser.create({ }) ``` -Learn more about this on the [Configuring your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names) page. +Learn more about this on the [Configuring your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) page. -As a next step, you will introspect your database. The result of the introspection will be a [data model](/concepts/components/prisma-schema/data-model) inside your Prisma schema. +As a next step, you will introspect your database. The result of the introspection will be a [data model](/orm/prisma-schema/data-model/models) inside your Prisma schema. Run the following command to introspect your database: @@ -675,13 +675,13 @@ Prisma's data model is a declarative representation of your database schema and Right now, there's a few minor "issues" with the data model: -- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. -- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. -- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/concepts/components/prisma-schema/data-model#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. +- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. +- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. +- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/orm/prisma-schema/data-model/models#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. -These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names). +These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names). -Because [relation fields](/concepts/components/prisma-schema/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: +Because [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: ```prisma file=prisma/schema.prisma highlight=7,14,22,23;edit model Post { @@ -710,7 +710,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names @@ -738,7 +738,7 @@ const user = await prisma.my_user.create({ }) ``` -If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/concepts/components/prisma-schema/data-model#mapping-model-names-to-tables-or-collections): +If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/orm/prisma-schema/data-model/models#mapping-model-names-to-tables-or-collections): ```prisma no-lines model MyUser { @@ -761,7 +761,7 @@ const user = await prisma.myUser.create({ }) ``` -Learn more about this on the [Configuring your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names) page. +Learn more about this on the [Configuring your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) page.
@@ -769,7 +769,7 @@ Learn more about this on the [Configuring your Prisma Client API](/concepts/comp -As a next step, you will introspect your database. The result of the introspection will be a [data model](/concepts/components/prisma-schema/data-model) inside your Prisma schema. +As a next step, you will introspect your database. The result of the introspection will be a [data model](/orm/prisma-schema/data-model/models) inside your Prisma schema. Run the following command to introspect your database: @@ -815,13 +815,13 @@ model User { -Refer to the [Prisma schema reference](/reference/api-reference/prisma-schema-reference) for detailed information about the schema definition. +Refer to the [Prisma schema reference](/orm/reference/prisma-schema-reference) for detailed information about the schema definition. Prisma's data model is a declarative representation of your database schema and serves as the foundation for the generated Prisma Client library. Your Prisma Client instance will expose queries that are _tailored_ to these models. -You will then need to add in any missing relations between your data using [relation fields](/concepts/components/prisma-schema/relations#relation-fields): +You will then need to add in any missing relations between your data using [relation fields](/orm/prisma-schema/data-model/relations#relation-fields): ```prisma file=prisma/schema.prisma highlight=8,17,27,28;add model Post { @@ -865,7 +865,7 @@ Prisma Migrate will now keep the manually added relation fields. Because relation fields are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database. -In this example, the database schema follows the [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions) for Prisma models. This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema follows the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models. This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names @@ -893,7 +893,7 @@ const user = await prisma.my_user.create({ }) ``` -If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/concepts/components/prisma-schema/data-model#mapping-model-names-to-tables-or-collections): +If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/orm/prisma-schema/data-model/models#mapping-model-names-to-tables-or-collections): ```prisma no-lines model MyUser { @@ -916,7 +916,7 @@ const user = await prisma.myUser.create({ }) ``` -Learn more about this on the [Configuring your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names) page. +Learn more about this on the [Configuring your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) page.
@@ -924,7 +924,7 @@ Learn more about this on the [Configuring your Prisma Client API](/concepts/comp -As a next step, you will introspect your database. The result of the introspection will be a [data model](/concepts/components/prisma-schema/data-model) inside your Prisma schema. +As a next step, you will introspect your database. The result of the introspection will be a [data model](/orm/prisma-schema/data-model/models) inside your Prisma schema. Run the following command to introspect your database: @@ -971,13 +971,13 @@ Prisma's data model is a declarative representation of your database schema and Right now, there's a few minor "issues" with the data model: -- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. -- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. -- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/concepts/components/prisma-schema/data-model#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. +- The `User` relation field is uppercased and therefore doesn't adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) . To express more "semantics", it would also be nice if this field was called `author` to _describe_ the relationship between `User` and `Post` better. +- The `Post` and `Profile` relation fields on `User` as well as the `User` relation field on `Profile` are all uppercased. To adhere to Prisma's [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions-1) , both fields should be lowercased to `post`, `profile` and `user`. +- Even after lowercasing, the `post` field on `User` is still slightly misnamed. That's because it actually refers to a [list](/orm/prisma-schema/data-model/models#type-modifiers) of posts – a better name therefore would be the plural form: `posts`. -These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names). +These changes are relevant for the generated Prisma Client API where using lowercased relation fields `author`, `posts`, `profile` and `user` will feel more natural and idiomatic to JavaScript/TypeScript developers. You can therefore [configure your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names). -Because [relation fields](/concepts/components/prisma-schema/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: +Because [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database: ```prisma file=prisma/schema.prisma highlight=8,15,22,23;edit model Post { @@ -1006,7 +1006,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/reference/api-reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names @@ -1034,7 +1034,7 @@ const user = await prisma.my_user.create({ }) ``` -If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/concepts/components/prisma-schema/data-model#mapping-model-names-to-tables-or-collections): +If you don't want to use the table and column names from your database in your Prisma Client API, you can configure them with [`@map` and `@@map`](/orm/prisma-schema/data-model/models#mapping-model-names-to-tables-or-collections): ```prisma no-lines model MyUser { @@ -1057,7 +1057,7 @@ const user = await prisma.myUser.create({ }) ``` -Learn more about this on the [Configuring your Prisma Client API](/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names) page. +Learn more about this on the [Configuring your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) page.
diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx index 19ed32d4c1..88f71c91ac 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx @@ -9,11 +9,11 @@ toc: false ## Create an initial migration -To use Prisma Migrate with the database you introspected in the last section, you will need to [baseline your database](/guides/migrate/developing-with-prisma-migrate/add-prisma-migrate-to-a-project). +To use Prisma Migrate with the database you introspected in the last section, you will need to [baseline your database](/orm/prisma-migrate/getting-started). Baselining refers to initializing your migration history for a database that might already contain data and **cannot be reset**, such as your production database. Baselining tells Prisma Migrate to assume that one or more migrations have already been applied to your database. -To baseline your database, use [`prisma migrate diff`](/reference/api-reference/command-reference#migrate-diff) to compare your schema and database, and save the output into a SQL file. +To baseline your database, use [`prisma migrate diff`](/orm/reference/prisma-cli-reference#migrate-diff) to compare your schema and database, and save the output into a SQL file. First, create a `migrations` directory and add a directory inside with your preferred name for the migration. In this example, we will use `0_init` as the migration name: diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/200-install-prisma-client.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/200-install-prisma-client.mdx index 7aeff88bf6..841bf540d8 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/200-install-prisma-client.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/200-install-prisma-client.mdx @@ -15,7 +15,7 @@ To get started with Prisma Client, you need to install the `@prisma/client` pack npm install @prisma/client ``` -Notice that the [`@prisma/client` node module](/concepts/components/prisma-client/working-with-prismaclient/generating-prisma-client#the-prismaclient-npm-package) references a folder named `.prisma/client`. The `.prisma/client` folder contains your generated Prisma Client, and is modified each time you change the schema and run the following command: +Notice that the [`@prisma/client` node module](/orm/prisma-client/setup-and-configuration/generating-prisma-client#the-prismaclient-npm-package) references a folder named `.prisma/client`. The `.prisma/client` folder contains your generated Prisma Client, and is modified each time you change the schema and run the following command: ```terminal copy npx prisma generate diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database.mdx index 209691e8d0..96c378cdef 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database.mdx @@ -75,7 +75,7 @@ Here's a quick overview of the different parts of the code snippet: 1. Call the `main` function 1. Close the database connections when the script terminates -Depending on what your models look like, the Prisma Client API will look different as well. For example, if you have a `User` model, your `PrismaClient` instance exposes a property called `user` on which you can call [CRUD](/concepts/components/prisma-client/crud) methods like `findMany`, `create` or `update`. The property is named after the model, but the first letter is lowercased (so for the `Post` model it's called `post`, for `Profile` it's called `profile`). +Depending on what your models look like, the Prisma Client API will look different as well. For example, if you have a `User` model, your `PrismaClient` instance exposes a property called `user` on which you can call [CRUD](/orm/prisma-client/queries/crud) methods like `findMany`, `create` or `update`. The property is named after the model, but the first letter is lowercased (so for the `Post` model it's called `post`, for `Profile` it's called `profile`). The following examples are all based on the models in the Prisma schema. @@ -195,9 +195,9 @@ async function main() {
-This code creates a new `User` record together with new `Post` and `Profile` records using a [nested write](/concepts/components/prisma-client/relation-queries#nested-writes) query. The `User` record is connected to the two other ones via the `Post.author` ↔ `User.posts` and `Profile.user` ↔ `User.profile` [relation fields](/concepts/components/prisma-schema/relations#relation-fields) respectively. +This code creates a new `User` record together with new `Post` and `Profile` records using a [nested write](/orm/prisma-client/queries/relation-queries#nested-writes) query. The `User` record is connected to the two other ones via the `Post.author` ↔ `User.posts` and `Profile.user` ↔ `User.profile` [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) respectively. -Notice that you're passing the [`include`](/concepts/components/prisma-client/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` and `profile` relations on the returned `User` objects. +Notice that you're passing the [`include`](/orm/prisma-client/queries/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` and `profile` relations on the returned `User` objects. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx index de4f4019a9..79d450cc4e 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx @@ -9,7 +9,7 @@ toc: false ## Add a `Tag` model to your schema -In this section, you will evolve your Prisma schema and then generate and apply the migration to your database with [`prisma migrate dev`](/reference/api-reference/command-reference#migrate-dev). +In this section, you will evolve your Prisma schema and then generate and apply the migration to your database with [`prisma migrate dev`](/orm/reference/prisma-cli-reference#migrate-dev). For the purpose of this guide, we'll make the following changes to the Prisma schema: diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx index b32313f5ac..4a2c944b59 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx @@ -9,11 +9,11 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/concepts/overview/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. ### Continue exploring the Prisma Client API -You can send a variety of queries with the Prisma Client API. Check out the [API reference](/concepts/components/prisma-client) and use your existing database setup from this guide to try them out. +You can send a variety of queries with the Prisma Client API. Check out the [API reference](/orm/prisma-client) and use your existing database setup from this guide to try them out. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx index 00668a1032..7ab09823a1 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['postgresql', 'mysql', 'sqlserver', 'planetscale', 'cockroachdb'] -Learn how to add Prisma to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/concepts/components/prisma-cli), [Prisma Client](/concepts/components/prisma-client), and [Prisma Introspection](/concepts/components/introspection). +Learn how to add Prisma to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Introspection](/orm/prisma-schema/introspection). @@ -18,7 +18,7 @@ Learn how to add Prisma to an existing Node.js or TypeScript project by connecti
-If you're migrating to Prisma from another ORM, see our [Migrate from TypeORM](/guides/migrate-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/guides/migrate-to-prisma/migrate-from-sequelize) migration guides. +If you're migrating to Prisma from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
@@ -55,8 +55,8 @@ In order to successfully complete this guide, you need: - [Node.js](https://nodejs.org/en/) installed on your machine - A [Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/?view=sql-server-ver15) database - - [Microsoft SQL Server on Linux for Docker](/concepts/database-connectors/sql-server/sql-server-docker) - - [Microsoft SQL Server on Windows (local)](/concepts/database-connectors/sql-server/sql-server-local) + - [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)
@@ -68,9 +68,9 @@ In order to successfully complete this guide, you need:
-> See [System requirements](/reference/system-requirements) for exact version requirements. +> See [System requirements](/orm/reference/system-requirements) for exact version requirements. -Make sure you have your database [connection URL](/reference/database-reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). ## Set up Prisma @@ -90,11 +90,11 @@ npx prisma -See [installation instructions](/reference/api-reference/command-reference#installation) to learn how to install Prisma using a different package manager. +See [installation instructions](/orm/tools/prisma-cli#installation) to learn how to install Prisma using a different package manager. -Next, set up your Prisma project by creating your [Prisma schema](/concepts/components/prisma-schema) file template with the following command: +Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file template with the following command: ```terminal copy npx prisma init @@ -103,7 +103,7 @@ npx prisma init This command does two things: - creates a new directory called `prisma` that contains a file called `schema.prisma`, which contains the Prisma schema with your database connection variable and schema models -- creates the [`.env` file](/guides/development-environment/environment-variables#using-env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) +- creates the [`.env` file](/orm/more/development-environment/environment-variables/env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/100-connect-your-database.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/100-connect-your-database.mdx index ae745ac8c9..5e976dcd74 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/100-connect-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/100-connect-your-database.mdx @@ -9,7 +9,7 @@ toc: false ## Connecting your database -To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/reference/database-reference/connection-urls): +To connect your database, you need to set the `url` field of the `datasource` block in your Prisma schema to your database [connection URL](/orm/reference/connection-urls): ```prisma file=prisma/schema.prisma datasource db { @@ -18,7 +18,7 @@ datasource db { } ``` -In this case, the `url` is [set via an environment variable](/guides/development-environment/environment-variables) which is defined in `.env`: +In this case, the `url` is [set via an environment variable](/orm/more/development-environment/environment-variables) which is defined in `.env`: ```bash file=.env DATABASE_URL="mongodb+srv://test:test@cluster0.ns1yp.mongodb.net/myFirstDatabase" @@ -26,7 +26,7 @@ DATABASE_URL="mongodb+srv://test:test@cluster0.ns1yp.mongodb.net/myFirstDatabase You now need to adjust the connection URL to point to your own database. -The [format of the connection URL](/reference/database-reference/connection-urls) for your database depends on the database you use. For MongoDB, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): +The [format of the connection URL](/orm/reference/connection-urls) for your database depends on the database you use. For MongoDB, it looks as follows (the parts spelled all-uppercased are _placeholders_ for your specific connection details): ```no-lines mongodb://USERNAME:PASSWORD@HOST:PORT/DATABASE diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx index f634b67997..2b5d5fa1c9 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx @@ -88,7 +88,7 @@ model User { ## Tweaking the Schema -To be able to join data using Prisma Client, you can add the [`@relation`](/reference/api-reference/prisma-schema-reference#relation) attributes to our models: +To be able to join data using Prisma Client, you can add the [`@relation`](/orm/reference/prisma-schema-reference#relation) attributes to our models: ```prisma file=prisma/schema.prisma highlight=14;add|20;add datasource db { diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/250-querying-the-database.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/250-querying-the-database.mdx index 0a5b773614..06769be5d7 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/250-querying-the-database.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/250-querying-the-database.mdx @@ -186,9 +186,9 @@ async function main() { -This code creates a new `User` record together with a new `Post` using a [nested write](/concepts/components/prisma-client/relation-queries#nested-writes) query. The `User` record is connected to the other one via the `Post.author` ↔ `User.posts` [relation fields](/concepts/components/prisma-schema/relations#relation-fields) respectively. +This code creates a new `User` record together with a new `Post` using a [nested write](/orm/prisma-client/queries/relation-queries#nested-writes) query. The `User` record is connected to the other one via the `Post.author` ↔ `User.posts` [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) respectively. -Notice that you're passing the [`include`](/concepts/components/prisma-client/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` relations on the returned `User` objects. +Notice that you're passing the [`include`](/orm/prisma-client/queries/select-fields#include-relations-and-select-relation-fields) option to `findMany` which tells Prisma Client to include the `posts` relations on the returned `User` objects. Run the code with this command: @@ -231,7 +231,7 @@ The output should look similar to this: -Also note that `allUsers` is _statically typed_ thanks to [Prisma Client's generated types](/concepts/components/prisma-client/advanced-type-safety/operating-against-partial-structures-of-model-types). You can observe the type by hovering over the `allUsers` variable in your editor. It should be typed as follows: +Also note that `allUsers` is _statically typed_ thanks to [Prisma Client's generated types](/orm/prisma-client/type-safety/operating-against-partial-structures-of-model-types). You can observe the type by hovering over the `allUsers` variable in your editor. It should be typed as follows: ```ts no-lines const allUsers: (User & { diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx index 0333f41319..628f0abc58 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx @@ -9,11 +9,11 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/concepts/overview/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. ### Continue exploring the Prisma Client API -You can send a variety of queries with the Prisma Client API. Check out the [API reference](/concepts/components/prisma-client) and use your existing database setup from this guide to try them out. +You can send a variety of queries with the Prisma Client API. Check out the [API reference](/orm/prisma-client) and use your existing database setup from this guide to try them out. diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx index 5ce63e5b5e..d88211470b 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['mongodb'] -Learn how to add Prisma to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/concepts/components/prisma-cli), [Prisma Client](/concepts/components/prisma-client), and [Prisma Introspection](/concepts/components/introspection). +Learn how to add Prisma to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Introspection](/orm/prisma-schema/introspection). @@ -18,7 +18,7 @@ Learn how to add Prisma to an existing Node.js or TypeScript project by connecti
-If you're migrating to Prisma from Mongoose, see our [Migrate from Mongoose guide](/guides/migrate-to-prisma/migrate-from-mongoose). +If you're migrating to Prisma from Mongoose, see our [Migrate from Mongoose guide](/orm/more/migrating-to-prisma/migrate-from-mongoose).
@@ -36,9 +36,9 @@ In order to successfully complete this guide, you need: -Make sure you have your database [connection URL](/reference/database-reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). -> See [System requirements](/reference/system-requirements) for exact version requirements. +> See [System requirements](/orm/reference/system-requirements) for exact version requirements. ## Set up Prisma @@ -56,7 +56,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`: npx prisma ``` -Next, set up your Prisma project by creating your [Prisma schema](/concepts/components/prisma-schema) file template with the following command: +Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file template with the following command: ```terminal copy npx prisma init @@ -65,7 +65,7 @@ npx prisma init This command does two things: - creates a new directory called `prisma` that contains a file called `schema.prisma`, which contains the Prisma schema with your database connection variable and schema models -- creates the [`.env` file](/guides/development-environment/environment-variables#using-env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) +- creates the [`.env` file](/orm/more/development-environment/environment-variables/env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection) diff --git a/content/100-getting-started/02-setup-prisma/index.mdx b/content/100-getting-started/02-setup-prisma/index.mdx index e497ffb55a..a5b8be18e0 100644 --- a/content/100-getting-started/02-setup-prisma/index.mdx +++ b/content/100-getting-started/02-setup-prisma/index.mdx @@ -8,10 +8,10 @@ staticLink: true -Start from scratch or add Prisma to an existing project. The following tutorials introduce you to the [Prisma CLI](/concepts/components/prisma-cli), [Prisma Client](/concepts/components/prisma-client), and [Prisma Migrate](/concepts/components/prisma-migrate). +Start from scratch or add Prisma to an existing project. The following tutorials introduce you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Migrate](/orm/prisma-migrate). ## In this section - + diff --git a/content/100-getting-started/index.mdx b/content/100-getting-started/index.mdx index 3aa8f6e95d..a017932ef8 100644 --- a/content/100-getting-started/index.mdx +++ b/content/100-getting-started/index.mdx @@ -8,13 +8,13 @@ metaDescription: 'Get started' Welcome to the Prisma getting started section! 👋 -Explore our range of products defined to make working with data easy: +Explore our range of products defined to make working with data easy: -[**Prisma ORM**](/concepts/overview/what-is-prisma) is an [open source](https://github.com/prisma/prisma) next-generation Node.js and TypeScript ORM that unlocks a new level of developer experience when working with databases thanks to its intuitive data model, automated migrations, type-safety & auto-completion. +[**Prisma ORM**](/orm/overview/introduction/what-is-prisma) is an [open source](https://github.com/prisma/prisma) next-generation Node.js and TypeScript ORM that unlocks a new level of developer experience when working with databases thanks to its intuitive data model, automated migrations, type-safety & auto-completion. -[**Prisma Accelerate**](/data-platform/accelerate/what-is-accelerate) is a global database cache with scalable connection pooling. +[**Prisma Accelerate**](/accelerate/what-is-accelerate) is a global database cache with scalable connection pooling. -[**Prisma Pulse**](/data-platform/pulse/what-is-pulse) allows you to build reactive, real-time applications in a type-safe manner. +[**Prisma Pulse**](/pulse/what-is-pulse) allows you to build reactive, real-time applications in a type-safe manner. @@ -78,11 +78,7 @@ If you're interested in learning how Prisma integrates with your favorite librar Add **Accelerate** to your app to use connection pooling and global database caching. - + Get started with Accelerate @@ -90,11 +86,7 @@ Add **Accelerate** to your app to use connection pooling and global database cac Add **Pulse** to your app to subscribe to real-time updates from your database using Prisma Client. - + Get started with Pulse diff --git a/content/200-concepts/100-components/02-prisma-client/000-working-with-prismaclient/index.mdx b/content/200-concepts/100-components/02-prisma-client/000-working-with-prismaclient/index.mdx deleted file mode 100644 index e3de19155d..0000000000 --- a/content/200-concepts/100-components/02-prisma-client/000-working-with-prismaclient/index.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: 'Working with PrismaClient' -metaTitle: 'Working with PrismaClient (Concepts)' -metaDescription: 'This page explains how to generate, configure, and instantiate Prisma Client, as well as when and how to manage database connections.' ---- - - - -This section describes how to generate, configure, and instantiate `PrismaClient` , as well as when and how to actively [manage connections](connection-management). - - - -## In this section - - diff --git a/content/200-concepts/100-components/02-prisma-client/058-transactions.mdx b/content/200-concepts/100-components/02-prisma-client/058-transactions.mdx deleted file mode 100644 index ed181f4cc1..0000000000 --- a/content/200-concepts/100-components/02-prisma-client/058-transactions.mdx +++ /dev/null @@ -1,458 +0,0 @@ ---- -title: 'Transactions and batch queries' -metaTitle: 'Transactions and batch queries (Reference)' -metaDescription: 'This page explains the transactions API of Prisma Client.' -tocDepth: 3 ---- - - - -A database transaction refers to a sequence of read/write operations that are _guaranteed_ to either succeed or fail as a whole. This section describes the ways in which the Prisma Client API supports transactions. - -- For more in-depth examples and use cases, refer to the 📖 [transactions guide](/guides/performance-and-optimization/prisma-client-transactions-guide). -- For information about transactions in general and the reasoning behind Prisma's current solutions, see ✍ [Blog: How Prisma supports transactions](https://www.prisma.io/blog/how-prisma-supports-transactions-x45s1d5l0ww1). - - - -## About transactions in Prisma - -Prisma provides the following options for using transactions: - -- [Nested writes](#nested-writes): use the Prisma Client API to process multiple operations on one or more related records inside the same transaction. -- [Batch / bulk transactions](#batchbulk-operations): process one or more operations in bulk with `updateMany`, `deleteMany`, and `createMany`. -- The `$transaction` API in Prisma Client: - - [Sequential operations](#sequential-prisma-client-operations): pass an array of Prisma Client queries to be executed sequentially inside a transaction, using `$transaction(queries: PrismaPromise[]): Promise`. - - [Interactive transactions](#interactive-transactions): pass a function that can contain user code including Prisma Client queries, non-Prisma code and other control flow to be executed in a transaction, using `$transaction(fn: (prisma: PrismaClient) => R, options?: object): R` - -## Nested writes - -A [nested write](relation-queries#nested-writes) lets you perform a single Prisma Client API call with multiple _operations_ that touch multiple [_related_](/concepts/components/prisma-schema/relations) records. For example, creating a _user_ together with a _post_ or updating an _order_ together with an _invoice_. Prisma Client ensures that all operations succeed or fail as a whole. - -The following example demonstrates a nested write with `create`: - -```ts -// Create a new user with two posts in a -// single transaction -const newUser: User = await prisma.user.create({ - data: { - email: 'alice@prisma.io', - posts: { - create: [ - { title: 'Join the Prisma Slack on https://slack.prisma.io' }, - { title: 'Follow @prisma on Twitter' }, - ], - }, - }, -}) -``` - -The following example demonstrates a nested write with `update`: - -```ts -// Change the author of a post in a single transaction -const updatedPost: Post = await prisma.post.update({ - where: { id: 42 }, - data: { - author: { - connect: { email: 'alice@prisma.io' }, - }, - }, -}) -``` - -> Refer to the 📖 [transactions guide](/guides/performance-and-optimization/prisma-client-transactions-guide#nested-writes) for more examples. - -## Batch/bulk operations - -The following bulk operations run as transactions: - -- `deleteMany` -- `updateMany` -- `createMany` - -> Refer to the 📖 [transactions guide](/guides/performance-and-optimization/prisma-client-transactions-guide#bulk-operations) for more examples. - -## The $transaction API - -The `$transaction` API can be used in two ways: - -- [Sequential operations](#sequential-prisma-client-operations): Pass an array of Prisma Client queries to be executed sequentially inside of a transaction. - - `$transaction(queries: PrismaPromise[]): Promise` - -- [Interactive transactions](#interactive-transactions): Pass a function that can contain user code including Prisma Client queries, non-Prisma code and other control flow to be executed in a transaction. - - `$transaction(fn: (prisma: PrismaClient) => R): R` - -### Sequential Prisma Client operations - -The following query returns all posts that match the provided filter as well as a count of all posts: - -```ts -const [posts, totalPosts] = await prisma.$transaction([ - prisma.post.findMany({ where: { title: { contains: 'prisma' } } }), - prisma.post.count(), -]) -``` - -You can also use raw queries inside of a `$transaction`: - -, ]}> - - - -```ts -const [userList, updateUser] = await prisma.$transaction([ - prisma.$queryRaw`SELECT 'title' FROM User`, - prisma.$executeRaw`UPDATE User SET name = 'Hello' WHERE id = 2;`, -]) -``` - - - - - -```ts -const [findRawData, aggregateRawData, commandRawData] = - await prisma.$transaction([ - prisma.user.findRaw({ - filter: { age: { $gt: 25 } }, - }), - prisma.user.aggregateRaw({ - pipeline: [ - { $match: { status: 'registered' } }, - { $group: { _id: '$country', total: { $sum: 1 } } }, - ], - }), - prisma.$runCommandRaw({ - aggregate: 'User', - pipeline: [ - { $match: { name: 'Bob' } }, - { $project: { email: true, _id: false } }, - ], - explain: false, - }), - ]) -``` - - - - - -Instead of immediately awaiting the result of each operation when it's performed, the operation itself is stored in a variable first which later is submitted to the database with a method called `$transaction`. Prisma Client will ensure that either all three `create` operations succeed or none of them succeed. - -> **Note**: Operations are executed according to the order they are placed in the transaction. Using a query in a transaction does not influence the order of operations in the query itself. -> -> Refer to the 📖 [transactions guide](/guides/performance-and-optimization/prisma-client-transactions-guide#transaction-api) for more examples. - -From version 4.4.0, the sequential operations transaction API has a second parameter. You can use the following optional configuration option in this parameter: - -- `isolationLevel`: Sets the [transaction isolation level](#transaction-isolation-level). By default this is set to the value currently configured in your database. - -For example: - -```ts -await prisma.$transaction( - [ - prisma.resource.deleteMany({ where: { name: 'name' } }), - prisma.resource.createMany({ data }), - ], - { - isolationLevel: Prisma.TransactionIsolationLevel.Serializable, // optional, default defined by database configuration - } -) -``` - -### Interactive transactions - -Sometimes you need more control over what queries execute within a transaction. Interactive transactions are meant to provide you with an escape hatch. - - - -Interactive transactions are available in the following versions of Prisma: - -- Interactive transactions are generally available from version 4.7.0. -- In version 4.6, Data Proxy support for interactive transactions was available in preview. -- From version 2.29.0 to version 4.5, interactive transactions were available in preview, but did not support the [Data Proxy](/data-platform/classic-projects/data-proxy). - -If you use interactive transactions in preview from version 2.29.0 to 4.6.1 (included), you need to add the `interactiveTransactions` preview feature to the generator block of your Prisma schema. - - - -To use interactive transactions, you can pass an async function into [`$transaction`](/guides/performance-and-optimization/prisma-client-transactions-guide#transaction-api). - -The first argument passed into this async function is an instance of Prisma Client. Below, we will call this instance `tx`. Any Prisma call invoked on this `tx` instance is encapsulated into the transaction. - -Let's look at an example: - -Imagine that you are building an online banking system. One of the actions to perform is to send money from one person to another. - -As experienced developers, we want to make sure that during the transfer, - -- the amount doesn't disappear -- the amount isn't doubled - -This is a great use-case for interactive transactions because we need to perform logic in-between the writes to check the balance. - -In the example below, Alice and Bob each have $100 in their account. If they try to send more money than they have, the transfer is rejected. - -Alice is expected to be able to make 1 transfer for $100 while the other transfer would be rejected. This would result in Alice having $0 and Bob having $200. - -```tsx -import { PrismaClient } from '@prisma/client' -const prisma = new PrismaClient() - -function transfer(from: string, to: string, amount: number) { - return prisma.$transaction(async (tx) => { - // 1. Decrement amount from the sender. - const sender = await tx.account.update({ - data: { - balance: { - decrement: amount, - }, - }, - where: { - email: from, - }, - }) - - // 2. Verify that the sender's balance didn't go below zero. - if (sender.balance < 0) { - throw new Error(`${from} doesn't have enough to send ${amount}`) - } - - // 3. Increment the recipient's balance by amount - const recipient = await tx.account.update({ - data: { - balance: { - increment: amount, - }, - }, - where: { - email: to, - }, - }) - - return recipient - }) -} - -async function main() { - // This transfer is successful - await transfer('alice@prisma.io', 'bob@prisma.io', 100) - // This transfer fails because Alice doesn't have enough funds in her account - await transfer('alice@prisma.io', 'bob@prisma.io', 100) -} - -main() -``` - -In the example above, both `update` queries run within a database transaction. When the application reaches the end of the function, the transaction is **committed** to the database. - -If your application encounters an error along the way, the async function will throw an exception and automatically **rollback** the transaction. - -To catch the exception, you can wrap `$transaction` in a try-catch block: - -```js -try { - await prisma.$transaction(async (tx) => { - // Code running in a transaction... - }) -} catch (err) { - // Handle the rollback... -} -``` - -The transaction API has a second parameter. For interactive transactions, you can use the following optional configuration options in this parameter: - -- `maxWait`: The maximum amount of time Prisma Client will wait to acquire a transaction from the database. The default value is 2 seconds. -- `timeout`: The maximum amount of time the interactive transaction can run before being canceled and rolled back. The default value is 5 seconds. -- `isolationLevel`: Sets the [transaction isolation level](#transaction-isolation-level). By default this is set to the value currently configured in your database. - -For example: - -```jsx -await prisma.$transaction( - async (tx) => { - // Code running in a transaction... - }, - { - maxWait: 5000, // default: 2000 - timeout: 10000, // default: 5000 - isolationLevel: Prisma.TransactionIsolationLevel.Serializable, // optional, default defined by database configuration - } -) -``` - - - -**Use interactive transactions with caution**. Keeping transactions -open for a long time hurts database performance and can even cause deadlocks. -Try to avoid performing network requests and executing slow queries inside your -transaction functions. We recommend you get in and out as quick as possible! - - - -### Transaction isolation level - - - -This feature is not available on MongoDB, because MongoDB does not support isolation levels. - - - -You can set the transaction [isolation level](https://www.prisma.io/dataguide/intro/database-glossary#isolation-levels) for transactions. - - - -This is available in the following Prisma versions for interactive transactions from version 4.2.0, for sequential operations from version 4.4.0. - -In versions before 4.2.0 (for interactive transactions), or 4.4.0 (for sequential operations), you cannot configure the transaction isolation level at a Prisma level. Prisma does not explicitly set the isolation level, so the [isolation level configured in your database](#database-specific-information-on-isolation-levels) is used. - - - -#### Set the isolation level - -To set the transaction isolation level, use the `isolationLevel` option in the second parameter of the API. - -For sequential operations: - -```ts -await prisma.$transaction( - [ - // Prisma Client operations running in a transaction... - ], - { - isolationLevel: Prisma.TransactionIsolationLevel.Serializable, // optional, default defined by database configuration - } -) -``` - -For an interactive transaction: - -```jsx -await prisma.$transaction( - async (prisma) => { - // Code running in a transaction... - }, - { - isolationLevel: Prisma.TransactionIsolationLevel.Serializable, // optional, default defined by database configuration - maxWait: 5000, // default: 2000 - timeout: 10000, // default: 5000 - } -) -``` - -#### Supported isolation levels - -Prisma Client supports the following isolation levels if they are available in the underlying database: - -- `ReadUncommitted` -- `ReadCommitted` -- `RepeatableRead` -- `Snapshot` -- `Serializable` - -The isolation levels available for each database connector are as follows: - -| Database | `ReadUncommitted` | `ReadCommitted` | `RepeatableRead` | `Snapshot` | `Serializable` | -| ----------- | ----------------- | --------------- | ---------------- | ---------- | -------------- | -| PostgreSQL | ✔️ | ✔️ | ✔️ | No | ✔️ | -| MySQL | ✔️ | ✔️ | ✔️ | No | ✔️ | -| SQL Server | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| CockroachDB | No | No | No | No | ✔️ | -| SQLite | No | No | No | No | ✔️ | - -By default, Prisma Client sets the isolation level to the value currently configured in your database. - -The isolation levels configured by default in each database are as follows: - -| Database | Default | -| ----------- | ---------------- | -| PostgreSQL | `ReadCommitted` | -| MySQL | `RepeatableRead` | -| SQL Server | `ReadCommitted` | -| CockroachDB | `Serializable` | -| SQLite | `Serializable` | - -#### Database-specific information on isolation levels - -See the following resources: - -- [Transaction isolation levels in PostgreSQL](https://www.postgresql.org/docs/9.3/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-ISOLATION) -- [Transaction isolation levels in Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-transaction-isolation-level-transact-sql?view=sql-server-ver15) -- [Transaction isolation levels in MySQL](https://dev.mysql.com/doc/refman/8.0/en/innodb-transaction-isolation-levels.html) - -CockroachDB and SQLite only support the `Serializable` isolation level. - -### Transaction timing issues - - - -- The solution in this section does not apply to MongoDB, because MongoDB does not support [isolation levels](https://www.prisma.io/dataguide/intro/database-glossary#isolation-levels). -- The timing issues discussed in this section do not apply to CockroachDB and SQLite, because these databases only support the highest `Serializable` isolation level. - - - -When two or more transactions run concurrently in certain [isolation levels](https://www.prisma.io/dataguide/intro/database-glossary#isolation-levels), timing issues can cause write conflicts or deadlocks, such as the violation of unique constraints. For example, consider the following sequence of events where Transaction A and Transaction B both attempt to execute a `deleteMany` and a `createMany` operation: - -1. Transaction B: `createMany` operation creates a new set of rows. -1. Transaction B: The application commits transaction B. -1. Transaction A: `createMany` operation. -1. Transaction A: The application commits transaction A. The new rows conflict with the rows that transaction B added at step 2. - -This conflict can occur at the isolation level `ReadCommited`, which is the default isolation level in PostgreSQL and Microsoft SQL Server. To avoid this problem, you can set a higher isolation level (`RepeatableRead` or `Serializable`). You can set the isolation level on a transaction. This overrides your database isolation level for that transaction. - -To avoid transaction write conflicts and deadlocks on a transaction: - -1. On your transaction, use the `isolationLevel` parameter to `Prisma.TransactionIsolationLevel.Serializable`. - - This ensures that your application commits multiple concurrent or parallel transactions as if they were run serially. When a transaction fails due to a write conflict or deadlock, Prisma Client returns a [P2034 error](/reference/api-reference/error-reference#p2034). - -2. In your application code, add a retry around your transaction to handle any P2034 errors, as shown in this example: - - ```ts - import { Prisma, PrismaClient } from '@prisma/client' - - const prisma = new PrismaClient() - async function main() { - const MAX_RETRIES = 5 - let retries = 0 - - let result - while (retries < MAX_RETRIES) { - try { - result = await prisma.$transaction( - [ - prisma.user.deleteMany({ - where: { - /** args */ - }, - }), - prisma.post.createMany({ - data: { - /** args */ - }, - }), - ], - { - isolationLevel: Prisma.TransactionIsolationLevel.Serializable, - } - ) - break - } catch (error) { - if (error.code === 'P2034') { - retries++ - continue - } - throw error - } - } - } - ``` - - - -Before Prisma version 4.4.0, you could not set isolation levels on transactions. The isolation level in your database configuration always applied. - - diff --git a/content/200-concepts/100-components/03-prisma-migrate/050-get-started.mdx b/content/200-concepts/100-components/03-prisma-migrate/050-get-started.mdx deleted file mode 100644 index c9a7528a3c..0000000000 --- a/content/200-concepts/100-components/03-prisma-migrate/050-get-started.mdx +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: 'Get started with Prisma Migrate' -metaTitle: 'Get started with Prisma Migrate' -metaDescription: 'Get started with Prisma Migrate' -tocDepth: 3 ---- - - - -This page explains how to get started with migrating your schema in a development environment using Prisma Migrate. See [Developing with Prisma Migrate](/guides/migrate/developing-with-prisma-migrate) for a more in-depth development workflow. - - - -## Get started with Prisma Migrate - -To get started with Prisma Migrate in a development environment: - -1. Create a Prisma schema: - - ```prisma file=schema.prisma - datasource db { - provider = "postgresql" - url = env("DATABASE_URL") - } - - model User { - id Int @id @default(autoincrement()) - name String - posts Post[] - } - - model Post { - id Int @id @default(autoincrement()) - title String - published Boolean @default(true) - authorId Int - author User @relation(fields: [authorId], references: [id]) - } - ``` - - - - You can use [native type mapping attributes](supported-types-and-db-features#mapping-fields-to-a-specific-native-type) in your schema to decide which exact database type to create (for example, `String` can map to `varchar(100)` or `text`). - - - - - - 1. Create the first migration: - - - - - - ```terminal - prisma migrate dev --name init - ``` - - - - - - ```sql no-copy - -- CreateTable - CREATE TABLE "User" ( - "id" SERIAL, - "name" TEXT NOT NULL, - - PRIMARY KEY ("id") - ); - -- CreateTable - CREATE TABLE "Post" ( - "id" SERIAL, - "title" TEXT NOT NULL, - "published" BOOLEAN NOT NULL DEFAULT true, - "authorId" INTEGER NOT NULL, - - PRIMARY KEY ("id") - ); - - -- AddForeignKey - ALTER TABLE "Post" ADD FOREIGN KEY("authorId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - ``` - - - - > **Note**: If you do not provide a `--name`, Prisma CLI will prompt you for a name. - - - - Your Prisma schema is now in sync with your database schema and you have initialized a migration history: - - ``` - migrations/ - └─ 20210313140442_init/ - └─ migration.sql - ``` - -1. Add additional fields to your schema: - - ```prisma highlight=3;add - model User { - id Int @id @default(autoincrement()) - jobTitle String - name String - posts Post[] - } - ``` - -1. Create the second migration: - - - - - - ```terminal - prisma migrate dev --name added_job_title - ``` - - - - - - ```sql no-copy - -- AlterTable - ALTER TABLE "User" ADD COLUMN "jobTitle" TEXT NOT NULL; - ``` - - - - - - Your Prisma schema is once again in sync with your database schema, and your migration history contains two migrations: - - ``` - migrations/ - └─ 20210313140442_init/ - └─ migration.sql - └─ 20210313140442_added_job_title/ - └─ migration.sql - ``` - - - -You now have a migration history that you can [source control](/concepts/components/prisma-migrate/migration-histories#committing-the-migration-history-to-source-control) and use to [deploy changes to test environments and production](/concepts/components/prisma-migrate/migrate-development-production#production-and-testing-environments). diff --git a/content/200-concepts/100-components/03-prisma-migrate/150-db-push.mdx b/content/200-concepts/100-components/03-prisma-migrate/150-db-push.mdx deleted file mode 100644 index 020230babe..0000000000 --- a/content/200-concepts/100-components/03-prisma-migrate/150-db-push.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: 'Prototype your schema' -metaTitle: 'Prototype your schema' -metaDescription: 'Prototype your schema' -codeStyle: false ---- - - - -The Prisma CLI has a dedicated command for prototyping schemas: [`db push`](/reference/api-reference/command-reference#db-push) - -`db push` uses the same engine as Prisma Migrate to synchronize your Prisma schema with your database schema. The `db push` command: - -1. Introspects the database to infer and executes the changes required to make your database schema reflect the state of your Prisma schema. -2. By default, after changes have been applied to the database schema, generators are triggered (for example, Prisma Client). You do not need to manually invoke `prisma generate`. -3. If `db push` anticipates that the changes could result in data loss, it will: - - - Throw an error - - Require the `--accept-data-loss` option if you still want to make the changes - -> **Notes**: -> -> - `db push` does not interact with or rely on migrations. The migrations table `_prisma_migrations` will not be created or updated, and no migration files will be generated. -> - When working with PlanetScale, we recommend that you use `db push` instead of `migrate`. For details refer to our Getting Started documentation, either [Start from scratch](/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-planetscale) or [Add to existing project](/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-planetscale) depending on your situation. - - - -## Choosing db push or Prisma Migrate - -`db push` works well if: - -- You want to **quickly prototype and iterate** on schema design locally without the need to deploy these changes to other environments such as other developers, or staging and production environments. -- You are prioritizing reaching a **desired end-state** and not the changes or steps executed to reach that end-state (there is no way to preview changes made by `db push`) -- You do not need to control how schema changes impact data. There is no way to orchestrate schema and data migrations—if `db push` anticipates that changes will result in data loss, you can either accept data loss with the `--accept-data-loss` option or stop the process. There is no way to customize the changes. - -See [Schema prototyping with `db push`](/guides/migrate/prototyping-schema-db-push) for an example of how to use `db push` in this way. - -`db push` is **not recommended** if: - -- You want to replicate your schema changes in other environments without losing data. You can use `db push` for prototyping, but you should use migrations to commit the schema changes and apply these in your other environments. -- You want fine-grained control over how the schema changes are executed - for example, [renaming a column instead of dropping it and creating a new one](/guides/migrate/developing-with-prisma-migrate/customizing-migrations#example-rename-a-field). -- You want to keep track of changes made to the database schema over time. `db push` does not create any artifacts that allow you to keep track of these changes. -- You want the schema changes to be reversible. You can use `db push` again to revert to the original state, but this might result in data loss. - -## Can I use Prisma Migrate and db push together? - -Yes, you can [use `db push` and Prisma Migrate together in your development workflow](/guides/migrate/prototyping-schema-db-push) . For example, you can: - -- Use `db push` to prototype a schema at the start of a project and initialize a migration history when you are happy with the first draft -- Use `db push` to prototype a change to an existing schema, then run `prisma migrate dev` to generate a migration from your changes (you will be asked to reset) diff --git a/content/200-concepts/100-components/03-prisma-migrate/index.mdx b/content/200-concepts/100-components/03-prisma-migrate/index.mdx deleted file mode 100644 index 138b85f230..0000000000 --- a/content/200-concepts/100-components/03-prisma-migrate/index.mdx +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: 'Prisma Migrate' -metaTitle: 'Prisma Migrate | Database, Schema, SQL Migration Tool' -metaDescription: 'Prisma Migrate is a database migration tool available via the Prisma CLI that integrates with Prisma schema for data modeling.' -toc: false ---- - - - - - -**Does not apply for MongoDB**
Instead of `migrate dev` and related commands, use [`db push`](/concepts/components/prisma-migrate/db-push) for [MongoDB](/concepts/database-connectors/mongodb). - -
- -Prisma Migrate enables you to: - -- Keep your database schema in sync with your [Prisma schema](/concepts/components/prisma-schema) as it evolves _and_ -- Maintain existing data in your database - -Prisma Migrate generates [a history of `.sql` migration files](/concepts/components/prisma-migrate/migration-histories), and plays a role in both [development and production](/concepts/components/prisma-migrate/migrate-development-production). - -Prisma Migrate can be considered a _hybrid_ database schema migration tool, meaning it has both of _declarative_ and _imperative_ elements: - -- Declarative: The data model is described in a declarative way in the [Prisma schema](/concepts/components/prisma-schema). Prisma Migrate generates SQL migration files from that data model. -- Imperative: All generated SQL migration files are fully customizable. Prisma Migrate hence provides the flexibility of an imperative migration tool by enabling you to modify what and how migrations are executed (and allows you to run custom SQL to e.g. make use of native database feature, perform data migrations, ...). - - - -If you are prototyping, consider using the [`db push` command](db-push) - see [Schema prototyping with `db push`](/guides/migrate/prototyping-schema-db-push) for examples. - - - -See the [Prisma Migrate reference](/reference/api-reference/command-reference#prisma-migrate) for detailed information about the Prisma Migrate CLI commands. - -
- -## In this section - - diff --git a/content/200-concepts/100-components/05-prisma-cli.mdx b/content/200-concepts/100-components/05-prisma-cli.mdx deleted file mode 100644 index b4fc54e784..0000000000 --- a/content/200-concepts/100-components/05-prisma-cli.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: 'Prisma CLI' -metaTitle: '' -metaDescription: '' -toc: false ---- - - - -The Prisma command line interface (CLI) is the primary way to interact with your Prisma project from the command line. It can initialize new project assets, generate Prisma Client, and analyze existing database structures through introspection to automatically create your application models. - - - -## Prisma CLI command reference - -See [Prisma CLI command reference](/reference/api-reference/command-reference) for a complete list of commands. diff --git a/content/200-concepts/100-components/08-prisma-engines/200-query-engine.mdx b/content/200-concepts/100-components/08-prisma-engines/200-query-engine.mdx deleted file mode 100644 index 12f1da38c9..0000000000 --- a/content/200-concepts/100-components/08-prisma-engines/200-query-engine.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: 'Query engine' -metaTitle: 'Query engine (Concepts)' -metaDescription: "Prisma's query engine manages the communication with the database when using Prisma Client. Learn how it works on this page." ---- - - - -From a technical perspective, Prisma Client consists of three major components: - -- JavaScript client library -- TypeScript type definitions -- A query engine - -All of these components are located in the [generated `.prisma/client` folder](/concepts/components/prisma-client/working-with-prismaclient/generating-prisma-client#the-prismaclient-npm-package) after you ran `prisma generate`. - -This page covers relevant technical details about the query engine. - - - -## The query engine file - -The **query engine file** is different for each operating system. It is named `query-engine-PLATFORM` or `libquery_engine-PLATFORM` where `PLATFORM` corresponds to the name of a compile target. Query engine file extensions depend on the platform as well. As an example, if the query engine must run on a [Darwin]() operating system such as macOS Intel, it is called `libquery_engine-darwin.dylib.node` or `query-engine-darwin`. You can find an overview of all supported platforms [here](/reference/api-reference/prisma-schema-reference#binarytargets-options). - -The query engine file is downloaded into the `runtime` directory of the generated Prisma Client when `prisma generate` is called. - -Note that the query engine is implemented in Rust. The source code is located in the [`prisma-engines`](https://github.com/prisma/prisma-engines/) repository. - -## The query engine at runtime - -By default, Prisma Client loads the query engine as a [Node-API library](https://nodejs.org/api/n-api.html). You can alternatively [configure Prisma to use the query engine compiled as an executable binary](#configuring-the-query-engine), which is run as a sidecar process alongside your application. -The Node-API library approach is recommended since it reduces the communication overhead between Prisma Client and the query engine. - -![Diagram showing the query engine and Node.js at runtime](query-engine-node-js-at-runtime.png) - -The query engine is started when the first Prisma Client query is invoked or when the [`$connect()`](/concepts/components/prisma-client/working-with-prismaclient/connection-management) method is called on your `PrismaClient` instance. Once the query engine is started, it creates a [connection pool](/concepts/components/prisma-client/working-with-prismaclient/connection-pool) and manages the physical connections to the database. From that point onwards, Prisma Client is ready to send [queries](/concepts/components/prisma-client/crud) to the database (e.g. `findUnique`, `findMany`, `create`, ...). - -The query engine is stopped and the database connections are closed when [`$disconnect()`](/concepts/components/prisma-client/working-with-prismaclient/connection-management) is invoked. - -The following diagram depicts a "typical flow": - -1. `$connect()` is invoked on Prisma Client -1. The query engine is started -1. The query engine establishes connections to the database and creates connection pool -1. Prisma Client is now ready to send queries to the database -1. Prisma Client sends a `findMany()` query to the query engine -1. The query engine translates the query into SQL and sends it to the database -1. The query engine receives the SQL response from the database -1. The query engine returns the result as plain old JavaScript objects to Prisma Client -1. `$disconnect()` is invoked on Prisma Client -1. The query engine closes the database connections -1. The query engine is stopped - -![Typical flow of the query engine at run time](typical-flow-query-engine-at-runtime.png) - -## Responsibilities of the query engine - -The query engine has the following responsibilities in an application that uses Prisma Client: - -- manage physical database connections in connection pool -- receive incoming queries from the Prisma Client Node.js process -- generate SQL queries -- send SQL queries to the database -- process responses from the database and send them back to Prisma Client - -## Debugging the query engine - -You can access the logs of the query engine by setting the [`DEBUG`](/concepts/components/prisma-client/debugging) environment variable to `engine`: - -```terminal -export DEBUG="engine" -``` - -You can also get more visibility into the SQL queries that are generated by the query engine by setting the [`query` log level](/reference/api-reference/prisma-client-reference#log-levels) in Prisma Client: - -```ts -const prisma = new PrismaClient({ - log: ['query'], -}) -``` - -Learn more about [Debugging](/concepts/components/prisma-client/debugging) and [Logging](/concepts/components/prisma-client/working-with-prismaclient/logging). - -## Configuring the query engine - -### Defining the query engine type for Prisma Client - -[As described above](#the-query-engine-at-runtime) the default query engine is a Node-API library that is loaded into Prisma Client, but there is also an alternative implementation as an executable binary that runs in its own process. You can configure the query engine type by providing the `engineType` property to the Prisma Client `generator`: - -```prisma -generator client { - provider = "prisma-client-js" - engineType = "binary" -} -``` - -Valid values for `engineType` are `binary` and `library`. You can also use the environment variable [`PRISMA_CLIENT_ENGINE_TYPE`](/reference/api-reference/environment-variables-reference#prisma_client_engine_type) instead. - - - -- Until Prisma 3.x the default and only engine type available was `binary`, so there was no way to configure the engine type to be used by Prisma Client and Prisma CLI. -- From versions [2.20.0](https://github.com/prisma/prisma/releases/2.20.0) to 3.x the `library` engine type was available and used by default by [activating the preview feature flag](/concepts/components/preview-features/client-preview-features#enabling-a-prisma-client-preview-feature) "`nApi`" or using the `PRISMA_FORCE_NAPI=true` environment variable. - - - -### Defining the query engine type for Prisma CLI - -Prisma CLI also uses its own query engine for its own needs. You can configure it to use the binary version of the query engine by defining the environment variable [`PRISMA_CLI_QUERY_ENGINE_TYPE=binary`](/reference/api-reference/environment-variables-reference#prisma_cli_query_engine_type). diff --git a/content/200-concepts/100-components/08-prisma-engines/index.mdx b/content/200-concepts/100-components/08-prisma-engines/index.mdx deleted file mode 100644 index d787df29ff..0000000000 --- a/content/200-concepts/100-components/08-prisma-engines/index.mdx +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: 'Prisma engines' -metaTitle: 'Prisma engines' -metaDescription: 'Learn about Prisma internals and how it works "under the hood". Prisma tools are based on an engine-layer which manages the communication with the database.' ---- - - - -This page gives an overview of the Prisma internals and how it works "under the hood". - -Note that **this page does not contain any practical information that is relevant for _using_ Prisma**. It rather aims at providing a _mental model_ for what the Prisma toolkit _actually_ is and how the different tools that are available to developers are structured. - -If you're new to Prisma, be sure to check out the [Quickstart](/getting-started/quickstart) and [Introduction](/concepts/overview/what-is-prisma) pages first. - - - -## Prisma engines - -At the core of each module, there typically is a [Prisma engine](https://github.com/prisma/prisma-engines) that implements the core set of functionality. Engines are implemented in [Rust](https://www.rust-lang.org/) and expose a low-level API that is used by the higher-level interfaces. - -A Prisma engine is the **direct interface to the database**, any higher-level interfaces always communicate with the database _through_ the engine-layer. - -As an example, Prisma Client connects to the [query engine](/concepts/components/prisma-engines/query-engine) in order to read and write data in a database: - -![Prisma engine](typical-flow-query-engine-at-runtime.png) - -### Using custom engine libraries or binaries - -By default, all engine files are automatically downloaded into the `node_modules/@prisma/engines` folder when you install or update `prisma`, the Prisma CLI package. The [query engine](/concepts/components/prisma-engines/query-engine) is also copied to the generated Prisma Client when you call `prisma generate`. -You might want to use a [custom library or binary](https://github.com/prisma/prisma-engines) file if: - -- Automated download of engine files is not possible. -- You have created your own engine library or binary for testing purposes, or for an OS that is not officially supported. - -Use the following environment variables to specify custom locations for your binaries: - -- [`PRISMA_QUERY_ENGINE_LIBRARY`](/reference/api-reference/environment-variables-reference#prisma_query_engine_library) (Query engine, library) -- [`PRISMA_QUERY_ENGINE_BINARY`](/reference/api-reference/environment-variables-reference#prisma_query_engine_binary) (Query engine, binary) -- [`PRISMA_SCHEMA_ENGINE_BINARY`](/reference/api-reference/environment-variables-reference#prisma_schema_engine_binary) (Schema engine) -- [`PRISMA_MIGRATION_ENGINE_BINARY`](/reference/api-reference/environment-variables-reference#prisma_migration_engine_binary) (Migration engine) -- [`PRISMA_INTROSPECTION_ENGINE_BINARY`](/reference/api-reference/environment-variables-reference#prisma_introspection_engine_binary) (Introspection engine) - - - -- `PRISMA_MIGRATION_ENGINE_BINARY` variable is deprecated in [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0). -- The Introspection Engine is served by the Migration Engine from [4.9.0](https://github.com/prisma/prisma/releases/tag/4.9.0). Therefore, the `PRISMA_INTROSPECTION_ENGINE` environment variable will not be used. -- The `PRISMA_FMT_BINARY` variable is used in versions [4.2.0](https://github.com/prisma/prisma/releases/tag/4.2.0) or lower. - - - -#### Setting the environment variable - -You can define environment variables globally on your machine or in the `.env` file. - -##### a) The `.env` file - -Add the environment variable to the [`.env` file](/guides/development-environment/environment-variables#using-env-files). - -, ]} - defaultTabType="OS" -> - - - -``` -PRISMA_QUERY_ENGINE_BINARY=custom/my-query-engine-unix -``` - - - - -``` -PRISMA_QUERY_ENGINE_BINARY=c:\custom\path\my-query-engine-binary.exe -``` - - - - -> **Note**: It is possible to [use an `.env` file in a location outside the `prisma` folder](/guides/development-environment/environment-variables/managing-env-files-and-setting-variables). - -##### b) Global environment variable - -Run the following command to set the environment variable globally (in this example, `PRISMA_QUERY_ENGINE_BINARY`): - -, ]} - defaultTabType="OS" -> - - - -```terminal -export PRISMA_QUERY_ENGINE_BINARY=/custom/my-query-engine-unix -``` - - - - - -```terminal -set PRISMA_QUERY_ENGINE_BINARY=c:\custom\my-query-engine-windows.exe -``` - - - - - -#### Test your environment variable - -Run the following command to output the paths to all binaries: - -```terminal -npx prisma -v -``` - -The output shows that the query engine path comes from the `PRISMA_QUERY_ENGINE_BINARY` environment variable: - -, ]} - defaultTabType="OS" -> - - - -```terminal highlight=2;normal -Current platform : darwin -Query Engine : query-engine d6ff7119649922b84e413b3b69660e2f49e2ddf3 (at /custom/my-query-engine-unix) -Migration Engine : migration-engine-cli d6ff7119649922b84e413b3b69660e2f49e2ddf3 (at /myproject/node_modules/@prisma/engines/migration-engine-unix) -Introspection Engine : introspection-core d6ff7119649922b84e413b3b69660e2f49e2ddf3 (at /myproject/node_modules/@prisma/engines/introspection-engine-unix) -``` - - - - -```terminal highlight=2;normal -Current platform : windows -Query Engine : query-engine d6ff7119649922b84e413b3b69660e2f49e2ddf3 (at c:\custom\my-query-engine-windows.exe) -Migration Engine : migration-engine-cli d6ff7119649922b84e413b3b69660e2f49e2ddf3 (at c:\myproject\node_modules\@prisma\engines\migration-engine-windows.exe) -Introspection Engine : introspection-core d6ff7119649922b84e413b3b69660e2f49e2ddf3 (at c:\myproject\node_modules\@prisma\engines\introspection-engine-windows.exe) -``` - - - - - -### Hosting engines - -The [`PRISMA_ENGINES_MIRROR`](/reference/api-reference/environment-variables-reference#prisma_engines_mirror) environment variable allows you to host engine files via a private server, AWS bucket or other cloud storage. -This can be useful if you have a custom OS that requires custom-built engines. - -```terminal -PRISMA_ENGINES_MIRROR=https://my-aws-bucket -``` diff --git a/content/200-concepts/100-components/250-preview-features/080-cli-preview-features.mdx b/content/200-concepts/100-components/250-preview-features/080-cli-preview-features.mdx deleted file mode 100644 index ff3389a0ec..0000000000 --- a/content/200-concepts/100-components/250-preview-features/080-cli-preview-features.mdx +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: Prisma CLI Preview features -metaDescription: Prisma CLI features that are currently in Preview. -tocDepth: 3 ---- - - - -When we release a new Prisma CLI feature, it often starts in Preview so that you can test it and submit your feedback. After we improve the feature with your feedback and are satisfied with the internal test results, we promote the feature to general availability. - -For more information, see [ORM releases and maturity levels](/about/prisma/releases). - - - -## Currently active Preview features - -There are currently no [Preview](/about/prisma/releases#preview) features for Prisma CLI. - - - -## Preview features promoted to general availability - -In the list below, you can find a history of Prisma CLI 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. - -| Features | Released in Preview | Released in general availability | -| ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -| [`prisma migrate diff`](/guides/migrate/production-troubleshooting#fixing-failed-migrations-with-migrate-diff-and-db-execute) | [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0) | [3.13.0](https://github.com/prisma/prisma/releases/tag/3.13.0) | -| [`prisma db execute`](/guides/migrate/production-troubleshooting#fixing-failed-migrations-with-migrate-diff-and-db-execute) | [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0) | [3.13.0](https://github.com/prisma/prisma/releases/tag/3.13.0) | -| [`prisma db push`](/guides/migrate/prototyping-schema-db-push) | [2.10.0](https://github.com/prisma/prisma/releases/tag/2.10.0) | [2.22.0](https://github.com/prisma/prisma/releases/tag/2.22.0) | -| [`prisma migrate`](/concepts/components/prisma-migrate) | [2.13.0](https://github.com/prisma/prisma/releases/tag/2.13.0) | [2.19.0](https://github.com/prisma/prisma/releases/tag/2.19.0) | diff --git a/content/200-concepts/100-components/index.mdx b/content/200-concepts/100-components/index.mdx deleted file mode 100644 index a3d620d071..0000000000 --- a/content/200-concepts/100-components/index.mdx +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: 'Components' -metaTitle: 'Components' -metaDescription: 'Components' -staticLink: true -toc: false ---- - -## In this section - - diff --git a/content/200-concepts/200-database-connectors/07-mongodb.mdx b/content/200-concepts/200-database-connectors/07-mongodb.mdx deleted file mode 100644 index 0c0f05abbd..0000000000 --- a/content/200-concepts/200-database-connectors/07-mongodb.mdx +++ /dev/null @@ -1,244 +0,0 @@ ---- -title: 'MongoDB' -metaTitle: 'MongoDB database connector' -metaDescription: 'How Prisma can connect to a MongoDB database using the MongoDB database connector.' -hidePage: false -tocDepth: 3 -codeStyle: false ---- - - - -The MongoDB data source connector connects Prisma to a hosted [MongoDB](https://www.mongodb.com/) instance. - - - -To connect Prisma with MongoDB, refer to our [Getting Started documentation](/getting-started/setup-prisma/start-from-scratch/mongodb-typescript-mongodb). - - - - - -## Example - -To connect to a MongoDB server, configure the [`datasource`](/concepts/components/prisma-schema/data-sources) block in your [Prisma schema file](/concepts/components/prisma-schema): - -```prisma file=schema.prisma -datasource db { - provider = "mongodb" - url = env("DATABASE_URL") -} -``` - -The fields passed to the `datasource` block are: - -- `provider`: Specifies the `mongodb` data source connector. -- `url`: Specifies the [connection URL](#connection-url) for the MongoDB server. In this case, an [environment variable is used](/guides/development-environment/environment-variables) to provide the connection URL. - - - -The MongoDB database connector uses transactions to support nested writes. Transactions **require** a [replica set](https://docs.mongodb.com/manual/tutorial/deploy-replica-set/) deployment. The easiest way to deploy a replica set is with [Atlas](https://docs.atlas.mongodb.com/getting-started/). It's free to get started. - - - -## Connection details - -### Connection URL - -The MongoDB connection URL can be configured in different ways depending on how you are hosting your database. The standard configuration is made up of the following components: - -![Structure of the MongoDB connection URL](./mongodb.png) - -#### Base URL and path - -The base URL and path sections of the connection URL are made up of your authentication credentials followed by the host (and optionally, a port number) and database. - -``` -mongodb://USERNAME:PASSWORD@HOST/DATABASE -``` - -The following components make up the _base URL_ of your database: - -| Name | Placeholder | Description | -| :------- | :---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| User | `USERNAME` | Name of your database user, e.g. `janedoe` | -| Password | `PASSWORD` | Password for your database user | -| Host | `HOST` | The host where a [`mongod`](https://docs.mongodb.com/manual/reference/program/mongod/#mongodb-binary-bin.mongod) instance is running. If you are running a sharded cluster this will a [`mongos`](https://docs.mongodb.com/manual/reference/program/mongos/#mongodb-binary-bin.mongos) instance. This can be a hostname, IP address or UNIX domain socket. | -| Port | `PORT` | Port on which your database server is running, e.g. `1234`. If none is provided the default `27017` is used. | -| Database | `DATABASE` | Name of the database to use. If none is specified but the `authSource` option is set then the `authSource` database name is used. If neither the database in the connection string nor the `authSource` option is specified then it defaults to `admin` | - - - -You must [percentage-encode special characters](/reference/database-reference/connection-urls#special-characters). - - - -#### Arguments - -A connection URL can also take arguments. The following example sets three arguments: - -- An `ssl` connection -- A `connectTimeoutMS` -- And the `maxPoolSize` - -``` -mongodb://USERNAME:PASSWORD@HOST/DATABASE?ssl=true&connectTimeoutMS=5000&maxPoolSize=50 -``` - -Refer to the [MongoDB connection string documentation](https://docs.mongodb.com/manual/reference/connection-string/#connection-string-options) for a complete list of connection string arguments. There are no Prisma-specific arguments. - -## Using ObjectId - -It is common practice for the `_id` field of a MongoDB document to contain an [ObjectId](https://docs.mongodb.com/manual/reference/bson-types/#std-label-objectid): - -```json -{ - "_id": { "$oid": "60d599cb001ef98000f2cad2" }, - "createdAt": { "$date": { "$numberLong": "1624611275577" } }, - "email": "ella@prisma.io", - "name": "Ella", - "role": "ADMIN" -} -``` - -Any field (most commonly IDs and relation scalar fields) that maps to an `ObjectId` in the underlying database: - -- Must be of type `String` or `Bytes` -- Must include the `@db.ObjectId` attribute -- Can optionally use `@default(auto())` to auto-generate a valid `ObjectId` on document creation - -Here is an example that uses `String`: - -```prisma -model User { - id String @id @default(auto()) @map("_id") @db.ObjectId - // Other fields -} -``` - -And here is another example that uses `Bytes`: - -```prisma -model User { - id Bytes @id @default(auto()) @map("_id") @db.ObjectId - // Other fields -} -``` - -See also: [Defining ID fields in MongoDB](/concepts/components/prisma-schema/data-model#defining-ids-in-mongodb) - -### Generating `ObjectId` - -To generate a valid `ObjectId` (for testing purposes or to manually set an ID field value) in your application, use the [`bson`](https://www.npmjs.com/package/bson) package. - -``` -npm install --save bson -``` - -```ts -import { ObjectId } from 'bson' - -const id = new ObjectId() -``` - -## Differences to connectors for relational databases - -This section covers ways in which the MongoDB connector differs from Prisma connectors for relational databases. - -### No support for Prisma Migrate - -Currently, there are no plans to add support for [Prisma Migrate](/concepts/components/prisma-migrate) as MongoDB projects do not rely on internal schemas where changes need to be managed with an extra tool. Management of `@unique` indexes is realized through `db push`. - -### No support for @@id and autoincrement() - -The [`@@id`](/reference/api-reference/prisma-schema-reference#id-1) attribute (an ID for multiple fields) is not supported because primary keys in MongoDB are always on the `_id` field of a model. - -The [`autoincrement()`](/reference/api-reference/prisma-schema-reference#generate-autoincrementing-integers-as-ids) function (which creates incrementing `@id` values) is not supported because `autoincrement()` does not work with the `ObjectID` type that the `_id` field has in MongoDB. - - - -### Cyclic references and referential actions - -If you have cyclic references in your models, either from self-relations or a cycle of relations between models, and you use [referential actions](/concepts/components/prisma-schema/relations/referential-actions), you must set a referential action of `NoAction` to prevent an infinite loop of actions. - -See [Special rules for referential actions](/concepts/components/prisma-schema/relations/referential-actions/special-rules-for-referential-actions) for more details. - -### Replica set configuration - -MongoDB only allows you to start a transaction on a replica set. Prisma uses transactions internally to avoid partial writes on nested queries. This means we inherit the requirement of needing a replica set configured. - -When you try to use Prisma's MongoDB connector on a deployment that has no replica set configured, Prisma shows the message `Error: Transactions are not supported by this deployment`. The full text of the error message is the following: - -``` -PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: -Invalid `prisma.post.create()` invocation in -/index.ts:9:21 - - 6 await prisma.$connect() - 7 - 8 // Create the first post -→ 9 await prisma.post.create( - Error in connector: Database error. error code: unknown, error message: Transactions are not supported by this deployment - at cb (/node_modules/@prisma/client/runtime/index.js:34804:17) - at processTicksAndRejections (internal/process/task_queues.js:97:5) { - clientVersion: '3.xx.0' -} -``` - -To resolve this, we suggest you change your deployment to one with a replica set configured. - -One simple way for this is to use [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) to launch a free instance that has replica set support out of the box. - -There's also an option to run the replica set locally with this guide: https://docs.mongodb.com/manual/tutorial/convert-standalone-to-replica-set - -## Type mapping between MongoDB and the Prisma schema - -The MongoDB connector maps the [scalar types](/concepts/components/prisma-schema/data-model#scalar-fields) from the Prisma [data model](/concepts/components/prisma-schema/data-model) to MongoDB's native column types as follows: - -> Alternatively, see [Prisma schema reference](/reference/api-reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma type. - -### Native type mapping from Prisma to MongoDB - -| Prisma | MongoDB | -| ---------- | ---------------------------------------------------------------------- | -| `String` | `string` | -| `Boolean` | `bool` | -| `Int` | `int` | -| `BigInt` | `long` | -| `Float` | `double` | -| `Decimal` | [Currently unsupported](https://github.com/prisma/prisma/issues/12637) | -| `DateTime` | `timestamp` | -| `Bytes` | `binData` | -| `Json` | | - -MongoDB types that are currently unsupported: - -- `Decimal128` -- `Undefined` -- `DBPointer` -- `Null` -- `Symbol` -- `MinKey` -- `MaxKey` -- `Object` -- `Javascript` -- `JavascriptWithScope` -- `Regex` - -### Mapping from MongoDB to Prisma types on Introspection - -When introspecting a MongoDB database, Prisma uses the relevant [scalar types](/concepts/components/prisma-schema/data-model#scalar-fields). Some special types also get additional native type annotations: - -| MongoDB (Type \| Aliases) | Prisma | Supported | Native database type attribute | Notes | -| ------------------------- | -------- | :-------: | :----------------------------- | :---- | -| `objectId` | `String` | ✔️ | `@db.ObjectId` | | - -[Introspection](/concepts/components/introspection) adds native database types that are **not yet supported** as [`Unsupported`](/reference/api-reference/prisma-schema-reference#unsupported) fields: - -```prisma file=schema.prisma -model Example { - id String @id @default(auto()) @map("_id") @db.ObjectId - name String - regex Unsupported("RegularExpression") -} -``` diff --git a/content/200-concepts/200-database-connectors/index.mdx b/content/200-concepts/200-database-connectors/index.mdx deleted file mode 100644 index 86f24e59fe..0000000000 --- a/content/200-concepts/200-database-connectors/index.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: 'Database connectors' -metaTitle: '' -metaDescription: '' -staticLink: true -toc: false ---- - -## Overview - -Prisma provides connectors for several databases. Refer to the [Database features](/reference/database-reference/database-features) section for information about supported features and types for each database. - -## In this section - - diff --git a/content/200-concepts/300-more/300-telemetry.mdx b/content/200-concepts/300-more/300-telemetry.mdx deleted file mode 100644 index 2d15e8b129..0000000000 --- a/content/200-concepts/300-more/300-telemetry.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: 'Telemetry' -metaTitle: 'Telemetry (Reference)' -metaDescription: 'This page explains how Prisma uses telemetry features to improve the Prisma developer experience.' ---- - -## Overview - -The term **telemetry** refers to the collection of certain usage data to help _improve the quality of a piece of software_. Prisma uses telemetry in two contexts: - -- when it collects CLI usage data -- when it submits CLI error reports - -This page describes the overall telemetry approach for Prisma, what kind of data is collected and how to opt-out of data collection. - -## Why does Prisma collect metrics? - -Telemetry helps us better understand _how many users_ are using our products and _how often_ they are using our products. Unlike many telemetry services, our telemetry implementation is intentionally limited in scope and is actually useful for the developer: - -- **Limited in scope**: We use telemetry to answer one question: how many monthly active developers are using Prisma CLI? -- **Provides value**: Our telemetry service also checks for version updates and offers security notices. - -## When is data collected? - -Data is collected in two scenarios that are described below. - -### Usage data - -Invocations of the `prisma` CLI and general usage of Studio results in data being sent to the telemetry server at https://checkpoint.prisma.io. Note that: - -- The data does **not** include your schema or the data in your database -- Prisma only sends information after you execute a CLI command - -Here is an overview of the data that's being submitted: - -| Field | Attributes | Description | -| -------------: | :--------: | :------------------------------------------------------------------------------------- | -| `product` | _string_ | Name of the product (e.g. `prisma`) | -| `version` | _string_ | Currently installed version of the product (e.g. `1.0.0-rc0`) | -| `arch` | _string_ | Client's operating system architecture (e.g. `amd64`). | -| `os` | _string_ | Client's operating system (e.g. `darwin`). | -| `node_version` | _string_ | Client's node version (e.g. `v12.12.0`). | -| `signature` | _string_ | Random, non-identifiable signature UUID (e.g. `91b014df3-9dda-4a27-a8a7-15474fd899f8`) | -| `user_agent` | _string_ | User agent of the checkpoint client (e.g. `prisma/js-checkpoint`) | -| `timestamp` | _string_ | When the request was made in RFC3339 format (e.g. `2019-12-12T17:45:56Z`) | - -You can opt-out of this behavior by setting the `CHECKPOINT_DISABLE` environment variable to `1`, e.g.: - -```terminal -export CHECKPOINT_DISABLE=1 -``` - -### Error reporting - -Prisma potentially collects error data when there is a crash in the CLI. - -Before an error report is submitted, there will _always_ be a prompt asking you to confirm or deny the submission of the error report! Error reports are never submitted without your explicit consent! - -## How to opt-out of data collection? - -### Usage data - -You can opt-out of usage data collection by setting the `CHECKPOINT_DISABLE` environment variable to `1`, e.g.: - -```terminal -export CHECKPOINT_DISABLE=1 -``` - -### Error reporting - -You can opt-out of data collection by responding to the interactive prompt with _no_. diff --git a/content/200-concepts/300-more/index.mdx b/content/200-concepts/300-more/index.mdx deleted file mode 100644 index 091b4751d7..0000000000 --- a/content/200-concepts/300-more/index.mdx +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: 'More' -metaTitle: 'Telemetry and Editor Setup' -metaDescription: 'In this section we cover other areas such as editor configuration for work with Prisma and telemetry.' -staticLink: true -toc: false ---- - -## In this section - - diff --git a/content/200-concepts/index.mdx b/content/200-concepts/index.mdx deleted file mode 100644 index e81e79036c..0000000000 --- a/content/200-concepts/index.mdx +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: 'Concepts' -metaTitle: 'Concepts' -metaDescription: 'Concepts' -toc: false ---- - - - -The concepts section of the documentation is a collection of topics that aim to expand upon and give explanation to, the different components that make up the Prisma ORM. - -The topics are organized into the following categories: - - - - - diff --git a/content/200-concepts/050-overview/100-what-is-prisma/index.mdx b/content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx similarity index 68% rename from content/200-concepts/050-overview/100-what-is-prisma/index.mdx rename to content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx index 33ed1cfb59..1ce8c749c4 100644 --- a/content/200-concepts/050-overview/100-what-is-prisma/index.mdx +++ b/content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx @@ -4,19 +4,9 @@ metaTitle: 'What is Prisma? (Overview)' metaDescription: "This page gives a high-level overview of what Prisma is and how it works. It's a great starting point for Prisma newcomers!" --- - - -This page gives a high-level overview of what Prisma is and how it works. - -If you want to get started with a _practical introduction_ and learn about the Prisma Client API, head over to the [**Getting Started**](/getting-started) documentation. - -To learn more about the _motivation_ for Prisma, check out the [**Why Prisma?**](/concepts/overview/why-prisma) page. - - - ## What is Prisma? -Prisma is an [open source](https://github.com/prisma/prisma) next-generation ORM. It consists of the following parts: +Prisma is an [open-source](https://github.com/prisma/prisma) next-generation ORM. It consists of the following parts: - **Prisma Client**: Auto-generated and type-safe query builder for Node.js & TypeScript - **Prisma Migrate**: Migration system @@ -24,11 +14,11 @@ Prisma is an [open source](https://github.com/prisma/prisma) next-generation ORM - **Prisma Studio** is the only part of Prisma ORM that is not open source. You can only run Prisma Studio locally. Prisma Studio is also integrated in our commercial offering [Prisma Data Platform](/data-platform/classic-projects/about) under the name [Data Browser](/data-platform/classic-projects/platform/data-browser). In Data Browser, you can view and edit data for each project and other team members can do the same after you grant them permissions with an appropriate [role](/data-platform/classic-projects/platform/members/roles-permissions). + **Prisma Studio** is the only part of Prisma ORM that is not open source. You can only run Prisma Studio locally. -Prisma Client can be used in _any_ Node.js (supported versions) or TypeScript backend application (including serverless applications and microservices). This can be a [REST API](../prisma-in-your-stack/rest), a [GraphQL API](../prisma-in-your-stack/graphql), a gRPC API, or anything else that needs a database. +Prisma Client can be used in _any_ Node.js (supported versions) or TypeScript backend application (including serverless applications and microservices). This can be a [REST API](/orm/overview/prisma-in-your-stack/rest), a [GraphQL API](/orm/overview/prisma-in-your-stack/graphql), a gRPC API, or anything else that needs a database.