1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/model/sql/enitites/DirectoryEntity.ts
2017-10-19 12:08:07 -04:00

37 lines
870 B
TypeScript

import {Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn} from "typeorm";
import {DirectoryDTO} from "../../../../common/entities/DirectoryDTO";
import {PhotoEntity} from "./PhotoEntity";
@Entity()
export class DirectoryEntity implements DirectoryDTO {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
path: string;
@Column('bigint')
public lastModified: number;
@Column('bigint')
public lastScanned: number;
@Column()
public scanned: boolean;
isPartial?: boolean;
@ManyToOne(type => DirectoryEntity, directory => directory.directories, {onDelete: "CASCADE"})
public parent: DirectoryEntity;
@OneToMany(type => DirectoryEntity, dir => dir.parent)
public directories: Array<DirectoryEntity>;
@OneToMany(type => PhotoEntity, photo => photo.directory)
public photos: Array<PhotoEntity>;
}