aboutsummaryrefslogtreecommitdiff
path: root/src/db/model/File.ts
blob: cc5e784c747fb167205ee9c2d4fddfeb6576c1d3 (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
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
  @NotNull
  name: string;

  @Column
  @PrimaryKey
  uuid: string;

  @Column
  mimetype: string;

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

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

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

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

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

  @BelongsTo(() => Project)
  rootFolderOf: Project;

  @CreatedAt
  uploadDate: Date;

  @UpdatedAt
  modifyDate: Date;
}