import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { SiteName } from './site-name';
import { Source } from './source';

/**
 * This non-user-maintained entity describes an online provider of works which can be scraped.
 */
@Entity()
export class Site implements IIdentifiableEntity, IMultiNamedEntity {
  @PrimaryGeneratedColumn()
  public id!: number;

  @Column({
    nullable: false,
    default: '',
  })
  public nameCanonical!: string;

  @OneToMany(() => SiteName, (siteName: SiteName) => siteName.entity)
  public names!: Promise<SiteName[]>;

  /**
   * sources belonging to this site
   */
  @OneToMany(() => Source, (source: Source) => source.site)
  public sources!: Promise<Source[]>;
}
