TypeORM이란?
- node.js에서 실행되고 타입스크립트로 작성된 객체 관계형 매퍼 라이브러리
ORM(Object Relational Mapping)이란?
- 객체와 관계형 데이터베이스의 데이터를 자동으로 변형 및 연결하는 작업이다.
- 객체와 데이터베이스의 변형에 유연하게 사용할 수 있다.
- 객체지향 프로그래밍은 클래스를 사용한다.
- 관계형 데이터베이스는 테이블을 사용한다.
- 과제 : 더 알아보자.
TypeORM 특징과 이점
- 모델을 기반으로 데이터베이스 테이블 체계를 자동으로 생성한다.
- 데이터베이스에서 개체를 쉽게 삽입, 업데이트 및 삭제할 수 있다.
- 테이블 간의 매핑을 만든다.
- 간단한 CLI 명령을 제공한다.
- 간단한 코딩으로 ORM 프레임워크를 사용할 수 있다.
설치해야 하는 모듈
- @nestjs/typeorm
- nestjs에서 TypeOrm을 사용하기 위해 연동시켜주는 모듈
npm install pg typeorm @nestjs/typeorm -save
명령어를 사용해 설치한다.
TypeORM 애플리케이션에 연결
-
TypeORM 설정파일 생성