RenaiApp/src/main/entities/library/book.ts

53 lines
1.2 KiB
TypeScript
Raw Normal View History

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