diff options
| author | Tom Harley | 2018-03-03 00:28:52 +0000 |
|---|---|---|
| committer | Tom Harley | 2018-03-03 00:28:52 +0000 |
| commit | 113b5dcbb948f96416f0b76ed8a8debff704c575 (patch) | |
| tree | d920f1e9c73e703505128a0c2e3099bb94c81033 /src/db/model/File.ts | |
| parent | Plug in authentication support - WIP (diff) | |
| parent | Add miniature response-wrapper middleware (diff) | |
| download | medicine-113b5dcbb948f96416f0b76ed8a8debff704c575.tar.gz medicine-113b5dcbb948f96416f0b76ed8a8debff704c575.zip | |
Merge branch ‘trh/gets’ into trh/payload-checker
Diffstat (limited to 'src/db/model/File.ts')
| -rw-r--r-- | src/db/model/File.ts | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/db/model/File.ts b/src/db/model/File.ts index 225512d..50c8e74 100644 --- a/src/db/model/File.ts +++ b/src/db/model/File.ts @@ -5,43 +5,55 @@ import { default as User } from './User'; @Table export default class File extends Model<File> { + @AllowNull @Column - public name: string = ''; + public name!: string; @PrimaryKey @Column - public uuid: string = ''; + public uuid!: string; @Column - public mimetype: string = ''; + public mimetype!: string; @ForeignKey(() => File) @AllowNull @Column(DataType.TEXT) - public parentFolderId: string | null = null; + public parentFolderId!: string | null; @BelongsTo(() => File) - public parentFolder: File = new File(); + public parentFolder?: File; @HasMany(() => File) - public containedFiles: File[] = []; + public containedFilesInternal?: File[]; @ForeignKey(() => User) @AllowNull @Column(DataType.TEXT) - public creatorName: string | null = null; + public creatorName!: string | null; @BelongsTo(() => User) - public creator: User = new User(); + public creator?: User; @HasOne(() => Project) - public rootFolderOf: Project = new Project(); + public rootFolderOf?: Project; @CreatedAt @Column - public uploadDate: Date = new Date(); + public uploadDate!: Date; @UpdatedAt @Column - public modifyDate: Date = new Date(); + 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; + } } |
