TypeORM & MySQL 적용하기

설치

yarn add @nestjs/typeorm
yarn add typeorm
yarn add mysql2

app.module.ts

import { TypeOrmModule } from '@nestjs/typeorm';

@Module({
  imports: [TypeOrmModule.forRoot()],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

ormconfig.env

TYPEORM_CONNECTION = mysql
TYPEORM_HOST = localhost
TYPEORM_USERNAME = 계정
TYPEORM_PASSWORD = 비밀번호
TYPEORM_DATABASE = DB명
TYPEORM_PORT = 3306
TYPEORM_SYNCHRONIZE = false
TYPEORM_LOGGING = true
TYPEORM_ENTITIES = dist/**/*.entity.js

테이블 동기화

yarn typeorm schema:sync

좋은 웹페이지 즐겨찾기