2020-04-10 05:02:19 +02:00
|
|
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
2020-04-10 04:04:13 +02:00
|
|
|
import { AuthorName } from './author-name';
|
|
|
|
import { WorkAuthor } from './work-author';
|
2019-06-23 02:30:24 +02:00
|
|
|
|
2020-04-10 04:04:13 +02:00
|
|
|
/**
|
|
|
|
* This entity represents a single real-world entity, be it a person or named group of persons.
|
|
|
|
*/
|
2019-06-23 02:30:24 +02:00
|
|
|
@Entity()
|
2021-01-06 02:35:46 +01:00
|
|
|
export class Author implements IdentifiableEntityInterface, MultiNamedEntityInterface {
|
2020-04-10 04:04:13 +02:00
|
|
|
@PrimaryGeneratedColumn()
|
2020-07-25 02:02:37 +02:00
|
|
|
public id!: number;
|
2020-04-10 04:04:13 +02:00
|
|
|
|
|
|
|
@Column({
|
2019-06-23 02:30:24 +02:00
|
|
|
nullable: false,
|
2020-08-18 00:29:49 +02:00
|
|
|
default: '',
|
2019-06-23 02:30:24 +02:00
|
|
|
})
|
2020-07-25 02:02:37 +02:00
|
|
|
public nameCanonical!: string;
|
2019-11-24 16:35:01 +01:00
|
|
|
|
2020-04-10 05:12:14 +02:00
|
|
|
@OneToMany(() => AuthorName, (authorName: AuthorName) => authorName.entity)
|
2020-07-25 02:02:37 +02:00
|
|
|
public names!: Promise<AuthorName[]>;
|
2020-04-10 04:04:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ultimately connects the author with a work and their role in that work
|
|
|
|
*/
|
2020-04-10 05:12:14 +02:00
|
|
|
@OneToMany(() => WorkAuthor, (workAuthor: WorkAuthor) => workAuthor.author)
|
2020-07-25 02:02:37 +02:00
|
|
|
public workAuthors!: Promise<WorkAuthor[]>;
|
2020-04-10 04:04:13 +02:00
|
|
|
}
|