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

@Entity(
    { name: "article_image" }
)
export default class ArticleImageEntity {

    @PrimaryGeneratedColumn()
    id?: number;

    @Column()
    link?: string;

    @Column({name: "cover_pos"})
    coverPos?: number;

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

    @JoinColumn({name: "id_media"})
    @ManyToOne(type => MediaEntity)
    media?: MediaEntity | null;

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

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

}