aboutsummaryrefslogtreecommitdiff
path: root/src/db/model/File.ts
blob: b8cf784ae6c42eaea6dfb7e6586f3295614caf95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {Table, Model, Column, Unique, PrimaryKey, ForeignKey, AllowNull,
        HasMany, BelongsTo, CreatedAt, UpdatedAt} from 'sequelize-typescript';
import { default as User } from './User';
import { default as Project } from './Project';

@Table
export default class File extends Model<File> {
  @Column
  name: string;

  @PrimaryKey
  @Column
  uuid: string;

  @Column
  mimetype: string;

  @ForeignKey(() => File)
  @AllowNull
  @Column
  parentFolderId: string;

  @BelongsTo(() => File)
  parentFolder: File;

  @HasMany(() => File)
  containedFiles: File[];

  @ForeignKey(() => User)
  @AllowNull
  @Column
  creatorName: string;

  @BelongsTo(() => User)
  creator: User;

  // @ForeignKey(() => Project)
  // @AllowNull
  // @Column
  // rootFolderOfProjectId: string;
  //
  // @BelongsTo(() => Project)
  // rootFolderOf: Project;

  @CreatedAt
  @Column
  uploadDate: Date;

  @UpdatedAt
  @Column
  modifyDate: Date;
}