You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/200-orm/100-prisma-schema/10-overview/02-data-sources.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@ metaDescription: 'Data sources enable Prisma to connect to your database. This p
6
6
7
7
A data source determines how Prisma ORM connects to your database, and is represented by the [`datasource`](/orm/reference/prisma-schema-reference#datasource) block in the Prisma schema. The following data source uses the `postgresql` provider and includes a connection URL:
8
8
9
+
::::note
10
+
As of Prisma ORM v7, the `url`, `directUrl`, and `shadowDatabaseUrl` fields in the Prisma schema `datasource` block are deprecated. Configure these fields in [Prisma Config](/orm/reference/prisma-config-reference) instead.
Copy file name to clipboardExpand all lines: content/200-orm/100-prisma-schema/10-overview/03-generators.mdx
+74-71Lines changed: 74 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,79 +15,10 @@ generator client {
15
15
16
16
A generator determines which assets are created when you run the `prisma generate` command.
17
17
18
-
There are two generators for Prisma Client:
19
-
20
-
-`prisma-client` (recommended): Newer and more flexible version of `prisma-client-js` with ESM support; it outputs plain TypeScript code and _requires_ a custom `output` path (read more about it [here](https://www.prisma.io/blog/why-prisma-orm-generates-code-into-node-modules-and-why-it-ll-change))
21
-
-`prisma-client-js`: Generates Prisma Client into `node_modules`
18
+
The default generator for Prisma Client is `prisma-client`, which outputs plain TypeScript code and _requires_ a custom `output` path (read more about it [here](https://www.prisma.io/blog/why-prisma-orm-generates-code-into-node-modules-and-why-it-ll-change)).
22
19
23
20
Alternatively, you can configure any npm package that complies with our generator specification.
24
21
25
-
## `prisma-client-js`
26
-
27
-
The `prisma-client-js` is the default generator for Prisma ORM 6.X versions and before. It requires the `@prisma/client` npm package and generates Prisma Client into `node_modules`.
28
-
29
-
### Field reference
30
-
31
-
The generator for Prisma's JavaScript Client accepts multiple additional properties:
32
-
33
-
-`previewFeatures`: [Preview features](/orm/reference/preview-features) to include
34
-
-`binaryTargets`: Engine binary targets for `prisma-client-js` (for example, `debian-openssl-1.1.x` if you are deploying to Ubuntu 18+, or `native` if you are working locally)
35
-
36
-
```prisma
37
-
generator client {
38
-
provider = "prisma-client-js"
39
-
previewFeatures = ["sample-preview-feature"]
40
-
binaryTargets = ["debian-openssl-1.1.x"] // defaults to `"native"`
41
-
}
42
-
```
43
-
44
-
### Binary targets
45
-
46
-
:::note
47
-
48
-
As of [v6.16.0](https://pris.ly/release/6.16.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).
49
-
50
-
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:
51
-
52
-
```prisma
53
-
generator client {
54
-
provider = "prisma-client-js" // or "prisma-client"
55
-
output = "../src/generated/prisma"
56
-
engineType = "client" // no Rust engine
57
-
}
58
-
```
59
-
60
-
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines.
61
-
62
-
When using Prisma ORM without Rust, the `binaryTargets` field is obsolete and not needed.
63
-
64
-
You can [read about the performance and DX improvements](https://www.prisma.io/blog/prisma-orm-without-rust-latest-performance-benchmarks) of this change on our blog.
65
-
66
-
:::
67
-
68
-
The `prisma-client-js` generator uses several [engines](https://github.com/prisma/prisma-engines). Engines are implemented in Rust and are used by Prisma Client in the form of executable, platform-dependent engine files. Depending on which platform you are executing your code on, you need the correct file. "Binary targets" are used to define which files should be present for the target platform(s).
69
-
70
-
The correct file is particularly important when [deploying](/orm/prisma-client/deployment/deploy-prisma) your application to production, which often differs from your local development environment.
71
-
72
-
#### The `native` binary target
73
-
74
-
The `native` binary target is special. It doesn't map to a concrete operating system. Instead, when `native` is specified in `binaryTargets`, Prisma Client detects the _current_ operating system and automatically specifies the correct binary target for it.
75
-
76
-
As an example, assume you're running **macOS** and you specify the following generator:
77
-
78
-
```prisma file=prisma/schema.prisma
79
-
generator client {
80
-
provider = "prisma-client-js"
81
-
binaryTargets = ["native"]
82
-
}
83
-
```
84
-
85
-
In that case, Prisma Client detects your operating system and finds the right binary file for it based on the [list of supported operating systems](/orm/reference/prisma-schema-reference#binarytargets-options) .
86
-
If you use macOS Intel x86 (`darwin`), then the binary file that was compiled for `darwin` will be selected.
87
-
If you use macOS ARM64 (`darwin-arm64`), then the binary file that was compiled for `darwin-arm64` will be selected.
88
-
89
-
> **Note**: The `native` binary target is the default. You can set it explicitly if you wish to include additional [binary targets](/orm/reference/prisma-schema-reference#binarytargets-options) for deployment to different environments.
90
-
91
22
## `prisma-client`
92
23
93
24
The new `prisma-client` generator offers greater control and flexibility when using Prisma ORM across different JavaScript environments (such as ESM, Bun, Deno, ...).
@@ -104,7 +35,7 @@ Here are the main differences compared to `prisma-client-js`:
104
35
- More flexible thanks to additional [fields](#field-reference)
105
36
- Outputs plain TypeScript that's bundled just like the rest of your application code
106
37
107
-
The `prisma-client` generator has been Generally Available since [v6.16.0](https://pris.ly/releases/6.16.0)will become the new default with Prisma ORM v7.
38
+
The `prisma-client` generator has been Generally Available since [v6.16.0](https://pris.ly/releases/6.16.0)and is the default generator as of Prisma ORM v7.
108
39
109
40
### Getting started
110
41
@@ -396,6 +327,78 @@ To see what the new `prisma-client` generator looks like in practice, check out
The `prisma-client-js` generator is **deprecated as of Prisma 7**. It was the default generator for Prisma ORM 6.X and earlier versions. We recommend migrating to [`prisma-client`](#prisma-client) for new projects and updating existing projects when possible.
335
+
336
+
:::
337
+
338
+
The `prisma-client-js` generator requires the `@prisma/client` npm package and generates Prisma Client into `node_modules`.
339
+
340
+
### Field reference
341
+
342
+
The generator for Prisma's JavaScript Client accepts multiple additional properties:
343
+
344
+
-`previewFeatures`: [Preview features](/orm/reference/preview-features) to include
345
+
-`binaryTargets`: Engine binary targets for `prisma-client-js` (for example, `debian-openssl-1.1.x` if you are deploying to Ubuntu 18+, or `native` if you are working locally)
346
+
347
+
```prisma
348
+
generator client {
349
+
provider = "prisma-client-js"
350
+
previewFeatures = ["sample-preview-feature"]
351
+
binaryTargets = ["debian-openssl-1.1.x"] // defaults to `"native"`
352
+
}
353
+
```
354
+
355
+
### Binary targets
356
+
357
+
:::note
358
+
359
+
As of [v6.16.0](https://pris.ly/release/6.16.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).
360
+
361
+
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:
362
+
363
+
```prisma
364
+
generator client {
365
+
provider = "prisma-client-js" // or "prisma-client"
366
+
output = "../src/generated/prisma"
367
+
engineType = "client" // no Rust engine
368
+
}
369
+
```
370
+
371
+
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines.
372
+
373
+
When using Prisma ORM without Rust, the `binaryTargets` field is obsolete and not needed.
374
+
375
+
You can [read about the performance and DX improvements](https://www.prisma.io/blog/prisma-orm-without-rust-latest-performance-benchmarks) of this change on our blog.
376
+
377
+
:::
378
+
379
+
The `prisma-client-js` generator uses several [engines](https://github.com/prisma/prisma-engines). Engines are implemented in Rust and are used by Prisma Client in the form of executable, platform-dependent engine files. Depending on which platform you are executing your code on, you need the correct file. "Binary targets" are used to define which files should be present for the target platform(s).
380
+
381
+
The correct file is particularly important when [deploying](/orm/prisma-client/deployment/deploy-prisma) your application to production, which often differs from your local development environment.
382
+
383
+
#### The `native` binary target
384
+
385
+
The `native` binary target is special. It doesn't map to a concrete operating system. Instead, when `native` is specified in `binaryTargets`, Prisma Client detects the _current_ operating system and automatically specifies the correct binary target for it.
386
+
387
+
As an example, assume you're running **macOS** and you specify the following generator:
388
+
389
+
```prisma file=prisma/schema.prisma
390
+
generator client {
391
+
provider = "prisma-client-js"
392
+
binaryTargets = ["native"]
393
+
}
394
+
```
395
+
396
+
In that case, Prisma Client detects your operating system and finds the right binary file for it based on the [list of supported operating systems](/orm/reference/prisma-schema-reference#binarytargets-options) .
397
+
If you use macOS Intel x86 (`darwin`), then the binary file that was compiled for `darwin` will be selected.
398
+
If you use macOS ARM64 (`darwin-arm64`), then the binary file that was compiled for `darwin-arm64` will be selected.
399
+
400
+
> **Note**: The `native` binary target is the default. You can set it explicitly if you wish to include additional [binary targets](/orm/reference/prisma-schema-reference#binarytargets-options) for deployment to different environments.
Copy file name to clipboardExpand all lines: content/200-orm/200-prisma-client/000-setup-and-configuration/010-generating-prisma-client.mdx
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,6 +124,35 @@ For improved compatibility with ECMAScript modules (ESM) and to ensure consisten
124
124
125
125
:::
126
126
127
+
## Loading environment variables
128
+
129
+
To load environment variables in your Prisma application, you can use the `prisma.config.ts` file along with the `env` helper from `prisma/config`. This approach provides better type safety and configuration management.
130
+
131
+
1. First, install the required dependency:
132
+
133
+
```bash
134
+
npm install dotenv --save-dev
135
+
```
136
+
137
+
2. Create a `.env` file in your project root (if it doesn't exist) and add your database connection string:
Copy file name to clipboardExpand all lines: content/200-orm/200-prisma-client/100-queries/100-query-optimization-performance.mdx
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,8 +42,6 @@ To get started, follow the [integration guide](/optimize/getting-started) and ad
42
42
43
43
You can also [log query events at the client level](/orm/prisma-client/observability-and-logging/logging#event-based-logging) to view the generated queries, their parameters, and execution times.
44
44
45
-
If you are particularly focused on monitoring query duration, consider using [logging middleware](/orm/prisma-client/client-extensions/middleware/logging-middleware).
Copy file name to clipboardExpand all lines: content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx
+1-18Lines changed: 1 addition & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Prisma Client extensions are Generally Available from versions 4.16.0 and later.
15
15
16
16
You can use the `query`[Prisma Client extensions](/orm/prisma-client/client-extensions) component type to hook into the query life-cycle and modify an incoming query or its result.
17
17
18
-
You can use Prisma Client extensions `query` component to create independent clients. This provides an alternative to [middlewares](/orm/prisma-client/client-extensions/middleware). You can bind one client to a specific filter or user, and another client to another filter or user. For example, you might do this to get [user isolation](/orm/prisma-client/client-extensions#extended-clients) in a row-level security (RLS) extension. In addition, unlike middlewares the `query` extension component gives you end-to-end type safety. [Learn more about `query` extensions versus middlewares](#query-extensions-versus-middlewares).
18
+
You can use Prisma Client extensions `query` component to create independent clients with customized behavior. You can bind one client to a specific filter or user, and another client to another filter or user. For example, you might do this to get [user isolation](/orm/prisma-client/client-extensions#extended-clients) in a row-level security (RLS) extension. The `query` extension component provides end-to-end type safety for all your custom queries.
You can use query extensions or [middlewares](/orm/prisma-client/client-extensions/middleware) to hook into the query life-cycle and modify an incoming query or its result. Client extensions and middlewares differ in the following ways:
289
-
290
-
- Middlewares always apply globally to the same client. Client extensions are isolated, unless you deliberately combine them. [Learn more about client extensions](/orm/prisma-client/client-extensions#about-prisma-client-extensions).
291
-
- For example, in a row-level security (RLS) scenario, you can keep each user in an entirely separate client. With middlewares, all users are active in the same client.
292
-
- During application execution, with extensions you can choose from one or more extended clients, or the standard Prisma Client. With middlewares, you cannot choose which client to use, because there is only one global client.
293
-
- Extensions benefit from end-to-end type safety and inference, but middlewares don't.
294
-
295
-
You can use Prisma Client extensions in all scenarios where middlewares can be used.
296
-
297
-
### If you use the `query` extension component and middlewares
298
-
299
-
If you use the `query` extension component and middlewares in your project, then the following rules and priorities apply:
300
-
301
-
- In your application code, you must declare all your middlewares on the main Prisma Client instance. You cannot declare them on an extended client.
302
-
- In situations where middlewares and extensions with a `query` component execute, Prisma Client executes the middlewares before it executes the extensions with the `query` component. Prisma Client executes the individual middlewares and extensions in the order in which you instantiated them with `$use` or `$extends`.
0 commit comments