// posts.entity.ts
import { Column, Entity } from 'typeorm';
@Entity()
export class PostsModel {
@PrimaryGeneratedColumn() // 프라이머리키 지정
id: number;
@Column()
author: string;
@Column()
title: string;
@Column()
content: string;
@Column()
likeCount: number;
@Column()
commentCount: number;
}
// app.module.ts
@Module({
imports: [
PostsModule,
TypeOrmModule.forRoot({
// 데이터베이스 타입
type: 'postgres',
// 엔드포인트
host: '127.0.0.1',
// 포트 (postgres 기본 5432)
port: 5432,
// 사용자 이름
username: 'postgres',
// 비밀번호
password: 'postgres',
// 데이터베이스 이름
database: 'postgres',
entities: [PostModel],
// 싱크 연동여부
synchronize: true, // 개발환경에서는 true
}),
],