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)
lang-js
$useis deprecated. Now it's$extendin the newer versions.