[NestJS] prisma

Younghwan Cha·2024년 2월 6일
0

Nest.js

목록 보기
27/27

nest.js 에서 prisma 를 사용하려면 prisma module 을 생성하고 아래와 같은 prisma.service.ts 파일을 작성하면 된다.

import { Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
  async onModuleInit() {
    await this.$connect();
  }
}

nest.js 공식문서 - prisma

profile
개발 기록

0개의 댓글