2020-04-10 05:02:19 +02:00
|
|
|
import { Column, Entity, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
2019-06-23 02:30:24 +02:00
|
|
|
import { Copy } from './copy';
|
|
|
|
import { Site } from './site';
|
|
|
|
|
|
|
|
@Entity()
|
2021-01-24 19:11:45 +01:00
|
|
|
export class Source implements SourceEntityInterface {
|
2020-04-10 04:04:13 +02:00
|
|
|
@PrimaryGeneratedColumn()
|
2021-01-24 19:11:45 +01:00
|
|
|
public readonly id!: number;
|
2020-04-10 04:04:13 +02:00
|
|
|
|
2019-06-23 02:30:24 +02:00
|
|
|
@Column({
|
|
|
|
nullable: false,
|
2020-08-18 00:29:49 +02:00
|
|
|
default: '',
|
2019-06-23 02:30:24 +02:00
|
|
|
})
|
2020-07-25 02:02:37 +02:00
|
|
|
public uri!: string;
|
2019-06-23 02:30:24 +02:00
|
|
|
|
2021-01-24 19:11:45 +01:00
|
|
|
@ManyToOne(() => Site, (site: SiteEntityInterface) => site.sources, {
|
2020-04-10 05:12:14 +02:00
|
|
|
nullable: true,
|
|
|
|
onDelete: 'RESTRICT',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
})
|
2021-01-24 19:11:45 +01:00
|
|
|
public site!: Promise<SiteEntityInterface> | null;
|
2019-06-23 02:30:24 +02:00
|
|
|
|
2021-01-24 19:11:45 +01:00
|
|
|
@ManyToMany(() => Copy, (copy: CopyEntityInterface) => copy.sources)
|
|
|
|
public copies!: Promise<CopyEntityInterface[]>;
|
2019-06-23 02:30:24 +02:00
|
|
|
}
|