😎 κ³΅λΆ€ν•˜λŠ” μ§•μ§•μ•ŒνŒŒμΉ΄λŠ” μ²˜μŒμ΄μ§€?

[Nest JS 둜 CRUD κ²Œμ‹œνŒ λ§Œλ“€κΈ°] (14) κ²Œμ‹œλ¬Όμ„ μœ„ν•œ μ—”ν‹°ν‹° (Entity) μƒμ„±ν•˜κΈ° λ³Έλ¬Έ

πŸ‘©‍πŸ’» λ°±μ—”λ“œ(Back-End)/Nest js

[Nest JS 둜 CRUD κ²Œμ‹œνŒ λ§Œλ“€κΈ°] (14) κ²Œμ‹œλ¬Όμ„ μœ„ν•œ μ—”ν‹°ν‹° (Entity) μƒμ„±ν•˜κΈ°

μ§•μ§•μ•ŒνŒŒμΉ΄ 2023. 6. 3. 22:34
728x90
λ°˜μ‘ν˜•

<λ³Έ λΈ”λ‘œκ·ΈλŠ” John Ahn μ˜ 유튜브λ₯Ό μ°Έκ³ ν•΄μ„œ κ³΅λΆ€ν•˜λ©° μž‘μ„±ν•˜μ˜€μŠ΅λ‹ˆλ‹€ :-)>

=> λ”°λΌν•˜λ©΄μ„œ λ°°μš°λŠ” NestJS

 

🧸 κ²Œμ‹œλ¬Όμ„ μœ„ν•œ μ—”ν‹°ν‹° (Entity) μƒμ„±ν•˜κΈ° 

πŸŽ€ Entity 생성 이유

: TypeORM 을 μ‚¬μš©ν•  λ•ŒλŠ” λ°μ΄ν„°λ² μ΄μŠ€ ν…Œμ΄λΈ”λ‘œ λ³€ν™˜λ˜λŠ” class 이기 λ•Œλ¬Έμ— 클래슀λ₯Ό μƒμ„±ν•œ ν›„ κ·Έ μ•ˆμ— μ»¬λŸΌλ“€μ„ μ •μ˜ν•¨

 

πŸŽ€ @Entity()

: Board ν΄λž˜μŠ€κ°€ μ—”ν‹°ν‹°μž„μ„ λ‚˜νƒ€λ‚΄λŠ”λ° μ‚¬μš©

 

πŸŽ€ @Entity()

: id 열이 Board μ—”ν‹°ν‹°μ˜ κΈ°λ³Έ ν‚€ μ—΄μž„μ„ λ‚˜νƒ€λ‚˜λŠ”λ° μ‚¬μš©

 

πŸŽ€ @Entity()

: Board μ—”ν„°ν‹°μ˜ title 및 description 같은 λ‹€λ₯Έ μ—΄ λ‚˜νƒ€λŠ”λ° μ‚¬μš© 

import { BaseEntity, Column, PrimaryGeneratedColumn } from "typeorm";
import { BoardStatus } from "./board.model";

export class Board extends BaseEntity {
    @PrimaryGeneratedColumn()
    id:number;

    @Column()
    title: string;

    @Column()
    description: string;

    @Column()
    status: BoardStatus;
}

 

728x90
λ°˜μ‘ν˜•
Comments