aboutsummaryrefslogtreecommitdiff
path: root/src/db/model/File.ts
blob: 09323e2447f19b99e5902832bab36346d4d5f299 (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
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';

@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;
 
  @HasOne(() => Project)
  rootFolderOf: Project;

  @CreatedAt
  @Column
  uploadDate: Date;

  @UpdatedAt
  @Column
  modifyDate: Date;
}