Introducing NestJS Prisma Library and Schematics #197
Replies: 2 comments
-
Great job, thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
-
@herenickname you can import // your module e.g user, products etc.
import { Module } from '@nestjs/common';
import { PrismaModule } from 'nestjs-prisma'; // 👈
import { UserController } from './user.controller';
import { UserService } from './user.service';
@Module({
imports: [PrismaModule], // 👈
controllers: [UserController],
providers: [UserService],
})
export class UserModule {} Now you can inject // controller
import { Controller, Get, Param } from '@nestjs/common';
import { UserService } from './app.service';
import { PrismaService } from 'nestjs-prisma'; // 👈
@Controller()
export class AppController {
constructor(
private prismaService: PrismaService, // 👈
private userService: UserService,
) {}
@Get()
...
}
//service
import { Injectable } from '@nestjs/common';
import { PrismaService } from 'nestjs-prisma'; // 👈
@Injectable()
export class UserService {
constructor(
private prisma: PrismaService // 👈
) {}
} Does that answer your question? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introducing NestJS Prisma Library and Schematics
Library and schematics to add Prisma integration to a NestJS application
https://notiz.dev/blog/nestjs-prisma-schematics
Beta Was this translation helpful? Give feedback.
All reactions