aboutsummaryrefslogtreecommitdiff
path: root/src/db/model/File.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/model/File.ts')
-rw-r--r--src/db/model/File.ts66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/db/model/File.ts b/src/db/model/File.ts
index 09323e2..225512d 100644
--- a/src/db/model/File.ts
+++ b/src/db/model/File.ts
@@ -1,47 +1,47 @@
-import {Table, Model, Column, Unique, PrimaryKey, ForeignKey, AllowNull,
- HasMany, BelongsTo, CreatedAt, UpdatedAt, HasOne} from 'sequelize-typescript';
-import { default as User } from './User';
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
- name: string;
+ @Column
+ public name: string = '';
+
+ @PrimaryKey
+ @Column
+ public uuid: string = '';
- @PrimaryKey
- @Column
- uuid: string;
+ @Column
+ public mimetype: string = '';
- @Column
- mimetype: string;
+ @ForeignKey(() => File)
+ @AllowNull
+ @Column(DataType.TEXT)
+ public parentFolderId: string | null = null;
- @ForeignKey(() => File)
- @AllowNull
- @Column
- parentFolderId: string;
+ @BelongsTo(() => File)
+ public parentFolder: File = new File();
- @BelongsTo(() => File)
- parentFolder: File;
+ @HasMany(() => File)
+ public containedFiles: File[] = [];
- @HasMany(() => File)
- containedFiles: File[];
+ @ForeignKey(() => User)
+ @AllowNull
+ @Column(DataType.TEXT)
+ public creatorName: string | null = null;
- @ForeignKey(() => User)
- @AllowNull
- @Column
- creatorName: string;
+ @BelongsTo(() => User)
+ public creator: User = new User();
- @BelongsTo(() => User)
- creator: User;
-
- @HasOne(() => Project)
- rootFolderOf: Project;
+ @HasOne(() => Project)
+ public rootFolderOf: Project = new Project();
- @CreatedAt
- @Column
- uploadDate: Date;
+ @CreatedAt
+ @Column
+ public uploadDate: Date = new Date();
- @UpdatedAt
- @Column
- modifyDate: Date;
+ @UpdatedAt
+ @Column
+ public modifyDate: Date = new Date();
}