aboutsummaryrefslogtreecommitdiff
path: root/src/db/model/File.ts
diff options
context:
space:
mode:
authorcjd242018-03-04 18:15:30 +0000
committercjd242018-03-04 18:15:30 +0000
commit955da66072042089cf457ab6406bfd7c97c4286f (patch)
tree379e4c4ea0bc008b3004b87b75bba8fc0348b18d /src/db/model/File.ts
parentPlaying around trying to get a list of base tiles we may be interested in for... (diff)
parentImplement handling of unauthorised requests (diff)
downloadmedicine-955da66072042089cf457ab6406bfd7c97c4286f.tar.gz
medicine-955da66072042089cf457ab6406bfd7c97c4286f.zip

Merge branch ‘trh/payload-checker’ into cjd24/conversion

Diffstat (limited to 'src/db/model/File.ts')
-rw-r--r--src/db/model/File.ts34
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;
+ }
}