38 lines
846 B
TypeScript
38 lines
846 B
TypeScript
import { Column, Entity, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { Copy } from './copy';
|
|
import { Site } from './site';
|
|
|
|
/**
|
|
* This entity describes an external source of a copy, in most cases that is a website.
|
|
*/
|
|
@Entity()
|
|
export class Source implements IIdentifiableEntity {
|
|
@PrimaryGeneratedColumn()
|
|
public id!: number;
|
|
|
|
/**
|
|
* the uri to the sauce
|
|
*/
|
|
@Column({
|
|
nullable: false,
|
|
default: '',
|
|
})
|
|
public uri!: string;
|
|
|
|
/**
|
|
* the site connected to the source
|
|
*/
|
|
@ManyToOne(() => Site, (site: Site) => site.sources, {
|
|
nullable: true,
|
|
onDelete: 'RESTRICT',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public site!: Promise<Site> | null;
|
|
|
|
/**
|
|
* the copies which can be found here
|
|
*/
|
|
@ManyToMany(() => Copy, (copy: Copy) => copy.sources)
|
|
public copies!: Promise<Copy[]>;
|
|
}
|