@dpliance/prisma
v1.0.1
Published
This library is a wrapper around the Prisma client. It provides a way to inject the Prisma client into your application.
Downloads
1
Readme
@dpliance/prisma
This library is a wrapper around the Prisma client. It provides a way to inject the Prisma client into your application.
Installation
pnpm install @dpliance/prisma
Configuration
prisma.service.ts
import { Injectable } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import { NestPrismaService } from '@dpliance/prisma';
const client = new PrismaClient();
@Injectable()
export class PrismaService extends NestPrismaService(client) {}
app.module.ts
import { PrismaModule } from '@dpliance/prisma';
import { PrismaService } from './prisma.service';
@Module({
imports: [
PrismaModule.forRoot({
use: PrismaService,
explicitConnect: true,
}),
],
})
export class AppModule {}
Usage
user.service.ts
import { Injectable } from '@nestjs/common';
import { PrismaService } from './prisma.service';
@Injectable()
export class UserService {
constructor(private readonly prisma: PrismaService) {}
async findMany() {
return this.prisma.user.findMany();
}
}
Building
Run nx build prisma
to build the library.
Running unit tests
Run nx test prisma
to execute the unit tests via Jest.