2019-06-23 02:30:24 +02:00
|
|
|
import { Entity, JoinTable, ManyToMany, OneToMany } from 'typeorm';
|
2019-11-22 21:22:13 +01:00
|
|
|
import { BaseEntity } from '../base-entity';
|
2019-06-23 02:30:24 +02:00
|
|
|
import { Author } from './author';
|
2019-11-24 16:35:01 +01:00
|
|
|
import { MultiName, MultiNamed } from './base/multi-named';
|
2019-06-23 15:35:57 +02:00
|
|
|
import { Character } from './character';
|
2019-06-23 02:30:24 +02:00
|
|
|
import { Copy } from './copy';
|
2019-06-23 15:35:57 +02:00
|
|
|
import { Fiction } from './fiction';
|
2019-06-23 02:30:24 +02:00
|
|
|
import { Tag } from './tag';
|
|
|
|
|
|
|
|
@Entity()
|
2019-12-01 15:12:41 +01:00
|
|
|
export class Book extends MultiNamed(BaseEntity, 'BookMultiName') {
|
2019-11-18 23:00:11 +01:00
|
|
|
@OneToMany(
|
|
|
|
() => Copy,
|
2019-11-24 18:23:16 +01:00
|
|
|
(copy: Copy) => copy.original
|
2019-11-18 23:00:11 +01:00
|
|
|
)
|
2019-06-23 02:30:24 +02:00
|
|
|
public copies: Promise<Copy[]>;
|
|
|
|
|
|
|
|
@ManyToMany(() => Author, {
|
|
|
|
nullable: true,
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
})
|
|
|
|
@JoinTable()
|
|
|
|
public authors: Promise<Author[]>;
|
|
|
|
|
2019-06-23 15:35:57 +02:00
|
|
|
@ManyToMany(() => Fiction, {
|
|
|
|
nullable: true,
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
})
|
|
|
|
@JoinTable()
|
|
|
|
public fictions: Promise<Fiction[]>;
|
|
|
|
|
|
|
|
@ManyToMany(() => Character, {
|
2019-06-23 02:30:24 +02:00
|
|
|
nullable: true,
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
})
|
|
|
|
@JoinTable()
|
2019-06-23 15:35:57 +02:00
|
|
|
public characters: Promise<Character[]>;
|
2019-06-23 02:30:24 +02:00
|
|
|
|
|
|
|
@ManyToMany(() => Tag, {
|
|
|
|
nullable: true,
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
})
|
|
|
|
@JoinTable()
|
|
|
|
public tags: Promise<Tag[]>;
|
|
|
|
}
|
2019-11-24 16:35:01 +01:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class BookMultiName extends MultiName('Book') {}
|