import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import ArticleEntity from "./article.entity";
import CategoryEntity from "./category.entity";

@Entity({name: "article_category"})
export default class ArticleCategoryEntity {

    @PrimaryGeneratedColumn()
    id?: number;

    @JoinColumn({name: "id_article"})
    @ManyToOne(type => ArticleEntity)
    article?: ArticleEntity;

    @JoinColumn({name: "id_category"})
    @ManyToOne(type => CategoryEntity)
    category?: CategoryEntity;

    @Column(
        { type: "datetime", name: "created_at" }
    )
    createdAt?: Date;

    @Column(
        { type: "datetime", name: "updated_at" }
    )
    updatedAt?: Date;

}