diff options
| author | Tom Harley | 2018-02-08 18:28:57 +0000 |
|---|---|---|
| committer | Tom Harley | 2018-02-08 18:28:57 +0000 |
| commit | d1f88d13f5c60cd0229d4267f92cd4d79f5fbff3 (patch) | |
| tree | ce54ab9c43b611455b658cf2eaf4fc3c5ea71732 /src/db/model/File.ts | |
| parent | added literal matching (diff) | |
| parent | configured server to use pg server on lab machines (diff) | |
| download | medicine-d1f88d13f5c60cd0229d4267f92cd4d79f5fbff3.tar.gz medicine-d1f88d13f5c60cd0229d4267f92cd4d79f5fbff3.zip | |
Merge branch ‘trh/db-orm’ into trh/payload-checker
Diffstat (limited to 'src/db/model/File.ts')
| -rw-r--r-- | src/db/model/File.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/db/model/File.ts b/src/db/model/File.ts new file mode 100644 index 0000000..bb5759d --- /dev/null +++ b/src/db/model/File.ts @@ -0,0 +1,48 @@ +import * from 'sequelize-typescript'; +import { default as User } from './User'; +import { default as Project } from './Project'; + +@Table +export default class File extends Model<File> { + @Column + @Unique + name: string; + + @Column + @PrimaryKey + uuid: string; + + @Column + mimetype: string; + + @Column + @ForeignKey(() => File) + @AllowNull + parentFolderId: string; + + @BelongsTo(() => File) + @AllowNull + parentFolder: File; + + @HasMany(() => File) + containedFiles: File[]; + + @Column + @ForeignKey(() => User) + @AllowNull + creatorName: string; + + @BelongsTo(() => User) + creator: User; + + @BelongsTo(() => Project) + rootFolderOf: Project; + + @Column + @CreatedAt + uploadDate: Date; + + @Column + @UpdatedAt + modifyDate: Date; +} |
