2019-01-06 23:15:52 +01:00
|
|
|
import {Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, Unique, Index} from 'typeorm';
|
2018-03-30 15:30:30 -04:00
|
|
|
import {DirectoryDTO} from '../../../../common/entities/DirectoryDTO';
|
2018-11-17 19:32:31 +01:00
|
|
|
import {MediaEntity} from './MediaEntity';
|
2018-11-26 00:26:29 +01:00
|
|
|
import {FileEntity} from './FileEntity';
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2017-02-05 16:19:35 +01:00
|
|
|
@Entity()
|
2018-12-09 11:37:12 +01:00
|
|
|
@Unique(['name', 'path'])
|
2016-12-28 12:30:26 +01:00
|
|
|
export class DirectoryEntity implements DirectoryDTO {
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2019-01-06 23:15:52 +01:00
|
|
|
@Index()
|
2017-07-15 17:48:29 +02:00
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
id: number;
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2019-01-06 23:15:52 +01:00
|
|
|
@Index()
|
2017-07-21 19:14:22 +02:00
|
|
|
@Column()
|
2017-07-15 17:48:29 +02:00
|
|
|
name: string;
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2019-01-06 23:15:52 +01:00
|
|
|
@Index()
|
2017-07-21 19:14:22 +02:00
|
|
|
@Column()
|
2017-07-15 17:48:29 +02:00
|
|
|
path: string;
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2017-12-19 11:19:48 -05:00
|
|
|
/**
|
2018-11-04 19:28:32 +01:00
|
|
|
* last time the directory was modified (from outside, eg.: a new media was added)
|
2017-12-19 11:19:48 -05:00
|
|
|
*/
|
2017-10-19 12:08:07 -04:00
|
|
|
@Column('bigint')
|
2017-07-19 20:47:09 +02:00
|
|
|
public lastModified: number;
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2017-12-19 11:19:48 -05:00
|
|
|
/**
|
2018-11-04 19:28:32 +01:00
|
|
|
* Last time the directory was fully scanned, not only for a few media to create a preview
|
2017-12-19 11:19:48 -05:00
|
|
|
*/
|
2018-03-30 15:30:30 -04:00
|
|
|
@Column({type: 'bigint', nullable: true})
|
2017-12-17 21:34:07 -05:00
|
|
|
public lastScanned: number;
|
2016-12-28 15:35:27 +01:00
|
|
|
|
2017-07-21 19:14:22 +02:00
|
|
|
isPartial?: boolean;
|
|
|
|
|
2019-01-06 23:15:52 +01:00
|
|
|
@Column('smallint')
|
|
|
|
mediaCount: number;
|
|
|
|
|
|
|
|
@Index()
|
2018-03-30 15:30:30 -04:00
|
|
|
@ManyToOne(type => DirectoryEntity, directory => directory.directories, {onDelete: 'CASCADE'})
|
2017-07-15 17:48:29 +02:00
|
|
|
public parent: DirectoryEntity;
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2017-07-15 17:48:29 +02:00
|
|
|
@OneToMany(type => DirectoryEntity, dir => dir.parent)
|
2018-11-17 19:32:31 +01:00
|
|
|
public directories: DirectoryEntity[];
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2018-11-17 19:32:31 +01:00
|
|
|
@OneToMany(type => MediaEntity, media => media.directory)
|
|
|
|
public media: MediaEntity[];
|
2016-12-27 20:55:51 +01:00
|
|
|
|
2018-11-26 00:26:29 +01:00
|
|
|
@OneToMany(type => FileEntity, file => file.directory)
|
|
|
|
public metaFile: FileEntity[];
|
|
|
|
|
2017-07-15 17:48:29 +02:00
|
|
|
}
|