If you are using Prisma ORM in your NestJS project and created your own custom Prisma service that extends the generated Prisma client, please read on.
Up until Prisma v6.13, your custom service followed this pattern:
import { PrismaClient } from 'my/generated/prisma/client/path';
export class PrismaService extends PrismaClient implements OnModuleInit {
...
Compiling this code with Prisma v6.14 generates an error. To fix it, your custom service should no longer extend PrismaClient
. Instead, declare a public property of type PrismaClient
and instantiate it in the constructor. This will be the client referenced elsewhere in your code to run database queries.
The new pattern:
import { PrismaClient } from 'my/generated/prisma/client/path';
export class PrismaService implements OnModuleInit {
readonly client: PrismaClient;
constructor() {
this.client = new PrismaClient();
}
...
Then elsewhere in your code:
@Injectable()
export class UsersService {
constructor(
private prisma: PrismaService,
) {}
async getUsers() {
return await this.prisma.client.user.findMany();
/* PREVIOUSLY: return await this.prisma.user.findMany(); */
}
Hopes this helps.
Top comments (0)