41 lines
994 B
TypeScript
41 lines
994 B
TypeScript
import { Entity, JoinTable, ManyToMany, OneToMany } from 'typeorm';
|
|
import { Author } from './author';
|
|
import { MultiNamed } from './bases/multiNamed';
|
|
import { Copy } from './copy';
|
|
import { IntellectualProperty } from './intellectualProperty';
|
|
import { Tag } from './tag';
|
|
|
|
@Entity()
|
|
export class Book extends MultiNamed {
|
|
@OneToMany(() => Copy, copy => copy.original, {
|
|
nullable: true,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public copies: Promise<Copy[]>;
|
|
|
|
@ManyToMany(() => Author, {
|
|
nullable: true,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
@JoinTable()
|
|
public authors: Promise<Author[]>;
|
|
|
|
@ManyToMany(() => IntellectualProperty, {
|
|
nullable: true,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
@JoinTable()
|
|
public intellectualProperties: Promise<IntellectualProperty[]>;
|
|
|
|
@ManyToMany(() => Tag, {
|
|
nullable: true,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
@JoinTable()
|
|
public tags: Promise<Tag[]>;
|
|
}
|