import { Entity, ManyToMany, PrimaryColumn } from 'typeorm';
import { Work } from './work';

/**
 * This entity is non-user-maintained and describes a language.
 */
@Entity()
export class Language {
  /**
   * ISO 639-1 two-letter language code
   */
  @PrimaryColumn()
  public code!: string;

  /**
   * the works using this language
   */
  @ManyToMany(() => Work, (work: Work) => work.languages)
  public works!: Promise<Work[]>;
}
