From b1eb22d8b4822aa86c232bac777921a29e1b94e8 Mon Sep 17 00:00:00 2001 From: NicoDora Date: Mon, 4 Sep 2023 17:16:51 +0900 Subject: [PATCH] feat(#1): comments entity add --- src/app.module.ts | 2 ++ src/comments/comment.module.ts | 8 ++++++++ src/comments/entities/comment.entity.ts | 23 +++++++++++++++++++++++ src/users/user.module.ts | 4 ---- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/comments/comment.module.ts create mode 100644 src/comments/entities/comment.entity.ts diff --git a/src/app.module.ts b/src/app.module.ts index 311e5e4..a191bbd 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,3 +1,4 @@ +import { CommentModule } from './comments/comment.module'; import { UserModule } from './users/user.module'; import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; @@ -17,6 +18,7 @@ import * as mongoose from 'mongoose'; @Module({ imports: [ + CommentModule, UserModule, TypeOrmModule.forRoot({ ...TypeORMconfig, // TypeORM 설정 객체 확장 diff --git a/src/comments/comment.module.ts b/src/comments/comment.module.ts new file mode 100644 index 0000000..681edc8 --- /dev/null +++ b/src/comments/comment.module.ts @@ -0,0 +1,8 @@ +import { Module } from '@nestjs/common'; + +@Module({ + imports: [], + controllers: [], + providers: [], +}) +export class CommentModule {} diff --git a/src/comments/entities/comment.entity.ts b/src/comments/entities/comment.entity.ts new file mode 100644 index 0000000..d45417f --- /dev/null +++ b/src/comments/entities/comment.entity.ts @@ -0,0 +1,23 @@ +import { Board } from "src/boards/entities/board.entity"; +import { User } from "src/users/entities/user.entity"; +import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; + +@Entity({ + name: 'comment' +}) +export class Comment { + @PrimaryGeneratedColumn() + id: number; + + @ManyToOne(() => User) + user: User; + + @ManyToOne(() => Board) + board: Board; + + @Column() + content: string; + + @CreateDateColumn({ name: 'create_at' }) + createAt: Date; +} \ No newline at end of file diff --git a/src/users/user.module.ts b/src/users/user.module.ts index 13b1462..16212b3 100644 --- a/src/users/user.module.ts +++ b/src/users/user.module.ts @@ -1,7 +1,3 @@ -/* -https://docs.nestjs.com/modules -*/ - import { Module } from '@nestjs/common'; @Module({