#typescript #next-js

Vote Entity

Oct 1, 2022


Vote 기능 화면


Vote 테이블 컬럼


Vote 엔티티 작성

import { Column, Entity, JoinColumn, ManyToOne } from "typeorm"
import BaseEntity from './Entity';
import Post from "./Post";
import { User } from "./User";

@Entity("votes")
export default class Vote extends BaseEntity {
    @Column()
    value: number;

    @ManyToOne(() => User)
    @JoinColumn({name: "username", referencedColumnName: "username"})
    user: User

    @Column()
    username: string;

    @Column({nullable: true})
    postId: number

    @ManyToOne(() => Post)
    post: Post;

    @Column({nullable: true})
    commentId: number;

    @ManyToOne(() => Comment)
    comment: Comment
}


*****

© 2021, Ritij Jain | Pudhina Fresh theme for Jekyll.