TypeORM entity

Entity 클래스는 타입 모델과 테이블 스키마를 한곳에 묶는다

데코레이터는 데이터베이스 컬럼 정보를 선언하고, 타입스크립트 필드는 애플리케이션 코드의 계약이 됩니다.

TypeScript class

User Entity

@PrimaryGeneratedColumn id: number
@Column unique email: string
@Column nullable age?: number
Database table

users

primary key 자동 증가 ID로 각 행을 식별합니다.
constraint 이메일 중복 방지처럼 DB 수준의 규칙을 둡니다.
null rule 선택 필드는 타입과 컬럼 옵션을 함께 맞춥니다.