import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { RadioStationGenreEntity } from './radio-station-genre.entity';
import { RadioStationEntity } from './radio-station.entity';

@Entity('radio_station_sub_genres')
export class RadioStationSubGenreEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column() genre_id: number;
    @Column({ type: 'varchar', length: 64 }) name: string;

    @ManyToOne(() => RadioStationGenreEntity, (genre) => genre.subgenres)
    @JoinColumn({ name: 'genre_id' })
    parent: RadioStationGenreEntity;

    @OneToMany(() => RadioStationEntity, (station) => station.parent)
    stations: RadioStationEntity[];
}
