import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import DocumentEntity from "./document.entity";
import UserEntity from "./user.entity";

@Entity({name: "document_user"})
export default class DocumentUserEntity {

    @PrimaryGeneratedColumn()
    id?: number;

    @Column()
    code?: string;

    @Column()
    title?: string;

    @JoinColumn({name: "id_user"})
    @ManyToOne(type => UserEntity)
    user?: UserEntity;

    @JoinColumn({name: "id_document"})
    @ManyToOne(type => DocumentEntity)
    document?: DocumentEntity;

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

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

}