2018-03-31 03:30:30 +08:00
|
|
|
import {Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn} from 'typeorm';
|
|
|
|
import {DirectoryDTO} from '../../../../common/entities/DirectoryDTO';
|
|
|
|
import {PhotoEntity} from './PhotoEntity';
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-02-05 23:19:35 +08:00
|
|
|
@Entity()
|
2016-12-28 19:30:26 +08:00
|
|
|
export class DirectoryEntity implements DirectoryDTO {
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-07-15 23:48:29 +08:00
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
id: number;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-07-22 01:14:22 +08:00
|
|
|
@Column()
|
2017-07-15 23:48:29 +08:00
|
|
|
name: string;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-07-22 01:14:22 +08:00
|
|
|
@Column()
|
2017-07-15 23:48:29 +08:00
|
|
|
path: string;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-12-20 00:19:48 +08:00
|
|
|
/**
|
|
|
|
* last time the directory was modified (from outside, eg.: a new photo was added)
|
|
|
|
*/
|
2017-10-20 00:08:07 +08:00
|
|
|
@Column('bigint')
|
2017-07-20 02:47:09 +08:00
|
|
|
public lastModified: number;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-12-20 00:19:48 +08:00
|
|
|
/**
|
|
|
|
* Last time the directory was fully scanned, not only for a few photos to create a preview
|
|
|
|
*/
|
2018-03-31 03:30:30 +08:00
|
|
|
@Column({type: 'bigint', nullable: true})
|
2017-12-18 10:34:07 +08:00
|
|
|
public lastScanned: number;
|
2016-12-28 22:35:27 +08:00
|
|
|
|
2017-07-22 01:14:22 +08:00
|
|
|
isPartial?: boolean;
|
|
|
|
|
2018-03-31 03:30:30 +08:00
|
|
|
@ManyToOne(type => DirectoryEntity, directory => directory.directories, {onDelete: 'CASCADE'})
|
2017-07-15 23:48:29 +08:00
|
|
|
public parent: DirectoryEntity;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-07-15 23:48:29 +08:00
|
|
|
@OneToMany(type => DirectoryEntity, dir => dir.parent)
|
|
|
|
public directories: Array<DirectoryEntity>;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-07-15 23:48:29 +08:00
|
|
|
@OneToMany(type => PhotoEntity, photo => photo.directory)
|
|
|
|
public photos: Array<PhotoEntity>;
|
2016-12-28 03:55:51 +08:00
|
|
|
|
2017-07-15 23:48:29 +08:00
|
|
|
}
|