diff options
| author | jw255 | 2018-03-03 14:53:31 +0000 |
|---|---|---|
| committer | jw255 | 2018-03-03 14:53:31 +0000 |
| commit | 0caebd4bfdfd9c8d7840fc379412d5d1f867575f (patch) | |
| tree | ab0cd04004080d97bb85bde517f49d32eac9aedf /src/db/model/File.ts | |
| parent | fixed compilation issues _2 (diff) | |
| download | medicine-0caebd4bfdfd9c8d7840fc379412d5d1f867575f.tar.gz medicine-0caebd4bfdfd9c8d7840fc379412d5d1f867575f.zip | |
pulled latest files from trh/payload-checker
Diffstat (limited to 'src/db/model/File.ts')
| -rw-r--r-- | src/db/model/File.ts | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/db/model/File.ts b/src/db/model/File.ts new file mode 100644 index 0000000..50c8e74 --- /dev/null +++ b/src/db/model/File.ts @@ -0,0 +1,59 @@ +import { default as Project } from './Project'; +import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany, + HasOne, Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript'; +import { default as User } from './User'; + +@Table +export default class File extends Model<File> { + @AllowNull + @Column + public name!: string; + + @PrimaryKey + @Column + public uuid!: string; + + @Column + public mimetype!: string; + + @ForeignKey(() => File) + @AllowNull + @Column(DataType.TEXT) + public parentFolderId!: string | null; + + @BelongsTo(() => File) + public parentFolder?: File; + + @HasMany(() => File) + public containedFilesInternal?: File[]; + + @ForeignKey(() => User) + @AllowNull + @Column(DataType.TEXT) + public creatorName!: string | null; + + @BelongsTo(() => User) + public creator?: User; + + @HasOne(() => Project) + public rootFolderOf?: Project; + + @CreatedAt + @Column + public uploadDate!: Date; + + @UpdatedAt + @Column + public modifyDate!: Date; + + public get containedFiles(): File[] { + if (this.containedFilesInternal === undefined) { + throw new Error('containedFiles is undefined'); + } + return this.containedFilesInternal; + } + + public set containedFiles(files: File[]) { + this.containedFilesInternal = files; + } +} |
