TYPEORM은 Type을 사용할 수 있고 NestJS와 연계하고 데이터베이스 상호작용 테스트를 할 수 있다. 필수는 아니지만 유용하다.
SQL문 대신 코드를 써서 쿼리를 작성할 수 있다.
Postgresql 홈페이지에서 다운로드 받기
Pgadmin GUI 다운로드 받기
데이터베이스 만들기
NestJS와 Postgresql 연동하기
npm install --save @nestjs/typeorm typeorm pg 명령어 실행하기
app.module.ts에 TypeOrmModule 추가하기
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { TypeOrmModule } from '@nestjs/typeorm';
import { RestaurantsModule } from './restaurants/restaurants.module';
@Module({
imports: [
GraphQLModule.forRoot({
autoSchemaFile: true,
}),
RestaurantsModule,
TypeOrmModule.forRoot({
type: "postgres",
host: "localhost",
port: 5432,
username: "ssh32",
password: "********",
database: "nuber-eats",
synchronize: true,
logging: true
// }).then(connection => {
// here you can start to work with your entities
// }).catch(error => console.log(error));
})
],
controllers: [],
providers: [],
})
export class AppModule {}
'Uber Eats' 카테고리의 다른 글
Uber Eats # 9 joi (0) | 2021.03.06 |
---|---|
Uber Eats # 8 dotenv (0) | 2021.03.06 |
Uber Eats # 6 validator (0) | 2021.03.06 |
Uber Eats # 5 Arguments, Mutation (0) | 2021.03.06 |
Uber Eats # 4 entity ObjectType (0) | 2021.03.06 |