44 lines
854 B
TypeScript
44 lines
854 B
TypeScript
import { Copy } from './copy';
|
|
import { Site } from './site';
|
|
import { Column, Entity, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
|
|
|
/**
|
|
* 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,
|
|
})
|
|
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>;
|
|
|
|
/**
|
|
* the copies which can be found here
|
|
*/
|
|
@ManyToMany(
|
|
() => Copy,
|
|
(copy: Copy) => copy.sources
|
|
)
|
|
public copies: Promise<Copy[]>;
|
|
}
|