import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { GangnetPersonCommentEntity } from './gangnet-person-comment.entity';
import { GangNetEntity } from './gangnet.entity';

@Entity('gangnet_person')
export class GangNetPersonEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) gangnet_id: number;
    @Column({ type: 'varchar', width: 50 }) name: string;
    @Column({ type: 'varchar', width: 40 }) association: string;
    @Column({ type: 'varchar', width: 500, default: null, nullable: true }) biography: string | null;
    @Column({ type: 'varchar', width: 128, default: null, nullable: true }) mugshot: string | null;
    @Column({ type: 'datetime' }) added_date: Date;
    @Column({ type: 'int' }) added_character_id: number;
    @Column({ type: 'varchar', width: 80 }) added_name: string;

    @OneToMany(() => GangnetPersonCommentEntity, (comments) => comments.gangnet_person)
    comments: GangnetPersonCommentEntity[];

    @ManyToOne(() => GangNetEntity, (net) => net.persons)
    @JoinColumn({ name: 'gangnet_id' })
    gangnet: GangNetEntity;
}
