import {Entity, Column, PrimaryGeneratedColumn, ManyToMany, JoinTable} from "typeorm";

export enum GuideType {
    GUIDE = "guide",
    MEME = "meme",
    MISC = "misc"
}

@Entity()
export class Guide {
    
    @PrimaryGeneratedColumn()
    id: number;

    @ManyToMany(type => GuideKeyword, keyword => keyword.relatedGuides)
    @JoinTable()
    keywords: GuideKeyword[];

    @Column()
    displayName: string;

    @Column()
    content: string;

    @Column({ type: "varchar" })
    type: GuideType;
}

@Entity()
export class GuideKeyword {

    @PrimaryGeneratedColumn()
    id: number;

    @Column({ unique: true })
    keyword: string;

    @ManyToMany(type => Guide, guide => guide.keywords)
    relatedGuides: Guide[];
}
