0

I’m setting up Prisma with NestJS. I created a PrismaModule and a PrismaService file. I want to add my own middleware for soft delete, but I’m facing an error.

generator client {
 provider = "prisma-client-js"
}
datasource db {
 provider = "postgresql"
 url = env("DATABASE_URL")
}
model User {
 id Int @id @default(autoincrement())
 email String @unique
 password String
 created_at DateTime @default(now())
 updated_at DateTime @updatedAt
 deleted_at DateTime?
 @@map("users")
}

My PrismaService

import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import * as type from "@src/prisma/types";
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
 constructor() {
 super();
 }
 async onModuleInit() {
 await this.$connect();
 this.$use(this.categorySoftDeleteMiddleware); // error is here
 }
}

The error I get Property '$use' does not exist on type 'PrismaService'.ts(2339)

2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Sep 10, 2025 at 22:06
  • Please share your prisma version. afaik $use is deprecated. Now it's $extend in the newer versions. Commented Sep 29, 2025 at 22:45

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.