aboutsummaryrefslogtreecommitdiff
path: root/src/db/model/File.ts
diff options
context:
space:
mode:
authorTom Harley2018-02-22 18:47:08 +0000
committerTom Harley2018-02-22 18:47:08 +0000
commit5dafe924bbbd5cc09901186ff74e4b68a6dcd52f (patch)
treeff4a76d6eaed5773d89d0da6a02d788ffe210abb /src/db/model/File.ts
parentMerge branch 'master' into trh/payload-checker (diff)
downloadmedicine-5dafe924bbbd5cc09901186ff74e4b68a6dcd52f.tar.gz
medicine-5dafe924bbbd5cc09901186ff74e4b68a6dcd52f.zip

Revert “Revert”Merge branch ‘trh/error-middleware’ into ‘master’""

This reverts commit 3198c6c2474101623e3b95bd038effe210c176a8.

Diffstat (limited to 'src/db/model/File.ts')
-rw-r--r--src/db/model/File.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/db/model/File.ts b/src/db/model/File.ts
new file mode 100644
index 0000000..225512d
--- /dev/null
+++ b/src/db/model/File.ts
@@ -0,0 +1,47 @@
+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> {
+ @Column
+ public name: string = '';
+
+ @PrimaryKey
+ @Column
+ public uuid: string = '';
+
+ @Column
+ public mimetype: string = '';
+
+ @ForeignKey(() => File)
+ @AllowNull
+ @Column(DataType.TEXT)
+ public parentFolderId: string | null = null;
+
+ @BelongsTo(() => File)
+ public parentFolder: File = new File();
+
+ @HasMany(() => File)
+ public containedFiles: File[] = [];
+
+ @ForeignKey(() => User)
+ @AllowNull
+ @Column(DataType.TEXT)
+ public creatorName: string | null = null;
+
+ @BelongsTo(() => User)
+ public creator: User = new User();
+
+ @HasOne(() => Project)
+ public rootFolderOf: Project = new Project();
+
+ @CreatedAt
+ @Column
+ public uploadDate: Date = new Date();
+
+ @UpdatedAt
+ @Column
+ public modifyDate: Date = new Date();
+}