Skip to content

Commit b48792b

Browse files
more middleware removed
1 parent 8b703f0 commit b48792b

4 files changed

Lines changed: 2 additions & 83 deletions

File tree

content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,20 +283,3 @@ const transactionExtension = Prisma.defineExtension((prisma) =>
283283
const prisma = new PrismaClient().$extends(transactionExtension)
284284
```
285285

286-
## Query extensions versus middlewares
287-
288-
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`.

content/200-orm/500-reference/050-prisma-client-reference.mdx

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5514,63 +5514,6 @@ The `$connect()` method establishes a physical connection to the database via Pr
55145514
55155515
The `$on()` method allows you to subscribe to [logging events](#log) or the [exit hook](/orm/prisma-client/setup-and-configuration/databases-connections/connection-management#exit-hooks).
55165516
5517-
### `$use()`
5518-
5519-
<Admonition type="warning">
5520-
5521-
`$use` is not available in [extended clients](/orm/prisma-client/client-extensions). Please [either migrate to query extensions](/orm/prisma-client/client-extensions/query) or use the `$use` method prior to extending your client.
5522-
5523-
</Admonition>
5524-
5525-
The `$use()` method adds [middleware](/orm/prisma-client/client-extensions/middleware) :
5526-
5527-
```ts
5528-
prisma.$use(async (params, next) => {
5529-
console.log('This is middleware!');
5530-
// Modify or interrogate params here
5531-
5532-
return next(params);
5533-
});
5534-
```
5535-
5536-
#### `next`
5537-
5538-
`next` represents the "next level" in the middleware stack, which could be the next middleware or the Prisma Query, depending on [where in the stack you are](/orm/prisma-client/client-extensions/middleware#running-order-and-the-middleware-stack).
5539-
5540-
#### `params`
5541-
5542-
`params` is an object with information to use in your middleware.
5543-
5544-
| Parameter | Description |
5545-
| :----------------- | :--------------------------------------------------------------------------------------------- |
5546-
| `action` | The query type - for example, `create` or `findMany`. |
5547-
| `args` | Arguments that were passed into the query - for example, `where`, `data`, or `orderBy` |
5548-
| `dataPath` | Populated if you use the [fluent API](/orm/prisma-client/queries/relation-queries#fluent-api). |
5549-
| `model` | The model type - for example, `Post` or `User`. |
5550-
| `runInTransaction` | Returns `true` if the query ran in the context of a [transaction](#transaction). |
5551-
5552-
:::tip
5553-
5554-
If you need the `model` property as a string, use: `String(params.model)`
5555-
5556-
:::
5557-
5558-
Example parameter values:
5559-
5560-
```js
5561-
{
5562-
args: { where: { id: 15 } },
5563-
dataPath: [ 'select', 'author', 'select', 'posts' ],
5564-
runInTransaction: false,
5565-
action: 'findMany',
5566-
model: 'Post'
5567-
}
5568-
```
5569-
5570-
#### Examples
5571-
5572-
See [middleware examples](/orm/prisma-client/client-extensions/middleware#samples).
5573-
55745517
### `$queryRawTyped`
55755518
55765519
See: [Using Raw SQL (`$queryRawTyped`)](/orm/prisma-client/using-raw-sql/typedsql).

content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ In the list below, you can find a history of Prisma Client and Prisma schema fea
8585
| [`transactionApi`](/orm/prisma-client/queries/transactions#the-transaction-api) | [2.1.0](https://github.com/prisma/prisma/releases/tag/2.1.0) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) |
8686
| [`connectOrCreate`](/orm/reference/prisma-client-reference#connectorcreate) | [2.1.0](https://github.com/prisma/prisma/releases/tag/2.1.0) | [2.11.0](https://github.com/prisma/prisma/releases/tag/2.11.0) |
8787
| [`atomicNumberOperations`](/orm/reference/prisma-client-reference#atomic-number-operations) | [2.6.0](https://github.com/prisma/prisma/releases/tag/2.6.0) | [2.10.0](https://github.com/prisma/prisma/releases/tag/2.10.0) |
88-
| [`insensitiveFilters` (PostgreSQL)](/orm/prisma-client/queries/filtering-and-sorting#case-insensitive-filtering) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | [2.8.0](https://github.com/prisma/prisma/releases/tag/2.8.0) |
89-
| [`middlewares`](/orm/prisma-client/client-extensions/middleware) | [2.3.0](https://github.com/prisma/prisma/releases/tag/2.3.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) |
88+
| [`insensitiveFilters` (PostgreSQL)](/orm/prisma-client/queries/filtering-and-sorting#case-insensitive-filtering) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) | [2.8.0](https://github.com/prisma/prisma/releases/tag/2.8.0) | | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) |
9089
| [`aggregateApi`](/orm/prisma-client/queries/aggregation-grouping-summarizing#aggregate) | [2.2.0](https://github.com/prisma/prisma/releases/tag/2.2.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) |
9190
| [`distinct`](/orm/reference/prisma-client-reference#distinct) | [2.3.0](https://github.com/prisma/prisma/releases/tag/2.3.0) | [2.5.0](https://github.com/prisma/prisma/releases/tag/2.5.0) |

content/300-accelerate/200-getting-started.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const prisma = new PrismaClient().$extends(withAccelerate())
148148

149149
If VS Code does not recognize the `$extends` method, refer to [this section](/accelerate/faq#vs-code-does-not-recognize-the-extends-method) on how to resolve the issue.
150150

151-
#### Using the Accelerate extension with other extensions or middleware
151+
#### Using the Accelerate extension with other extensions
152152

153153
Since [extensions are applied one after another](/orm/prisma-client/client-extensions#conflicts-in-combined-extensions), make sure you apply them in the correct order. Extensions cannot share behavior and the last extension applied takes precedence.
154154

@@ -158,12 +158,6 @@ If you are using [Prisma Optimize](/optimize) in your application, make sure you
158158
const prisma = new PrismaClient().$extends(withOptimize()).$extends(withAccelerate())
159159
```
160160

161-
If you are using [Prisma Middleware](/orm/prisma-client/client-extensions/middleware) in your application, make sure they are added before any Prisma Client extensions (like Accelerate). For example:
162-
163-
```ts
164-
const prisma = new PrismaClient().$use(middleware).$extends(withAccelerate())
165-
```
166-
167161
### 2.5. Use Accelerate in your database queries
168162

169163
The `withAccelerate` extension primarily does two things:

0 commit comments

Comments
 (0)