Problem
The current documentation shows individual middleware examples, but doesn't demonstrate how to properly chain multiple middleware together with proper TypeScript typing.
Suggested Addition
Add a section under the Middleware docs showing:
- How to compose multiple middleware
- How to handle typing when middleware modifies the query/result
- Best practices for middleware ordering
Example Code Needed
const prisma = new PrismaClient().$extends({
query: {
$allModels: {
async $allOperations({ model, operation, args, query }) {
// Logging middleware
const start = Date.now()
const result = await query(args)
console.log(`${model}.${operation} took ${Date.now() - start}ms`)
return result
}
}
}
})
Why This Matters
Many production apps need multiple middleware (logging, soft deletes, multi-tenancy). Clear examples would help adoption.