File size: 1,540 Bytes
b0984a9
 
 
 
 
 
 
 
 
 
 
9f03bd9
 
 
b0984a9
 
 
0d75d39
b0984a9
 
 
 
 
 
 
 
 
 
9f03bd9
b0984a9
9f03bd9
b0984a9
9f03bd9
 
b0984a9
fcab6da
0d75d39
b0984a9
9f03bd9
0d75d39
9f03bd9
b0984a9
0d75d39
 
 
 
 
 
 
 
 
9f03bd9
 
b0984a9
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  OneToMany,
  JoinColumn,
  Index,
} from 'typeorm';
import type { Relation } from 'typeorm';
import type { File } from './file.entity';
import type { User } from '../../auth/entities/user.entity';

@Entity('folders')
@Index(['parentFolderId'])
@Index(['createdBy'])
export class Folder {
  @PrimaryGeneratedColumn({ name: 'folder_id', type: 'bigint' })
  folderId: number;

  @Column({ name: 'folder_name', type: 'varchar', length: 255, nullable: false })
  folderName: string;

  @Column({ name: 'parent_folder_id', type: 'bigint', nullable: true })
  parentFolderId?: number;

  @ManyToOne('Folder', 'children', { nullable: true })
  @JoinColumn({ name: 'parent_folder_id' })
  parentFolder?: Relation<Folder>;

  @OneToMany('Folder', 'parentFolder')
  children: Relation<Folder>[];

  @Column({ name: 'created_by', type: 'bigint', unsigned: true, nullable: false })
  createdBy: number;

  @ManyToOne('User', { nullable: false })
  @JoinColumn({ name: 'created_by' })
  user?: Relation<User>;

  @Column({ name: 'path', type: 'text', nullable: true })
  path?: string;

  @Column({ name: 'level', type: 'int', default: 0 })
  level: number;

  @Column({ name: 'is_system_folder', type: 'tinyint', default: 0 })
  isSystemFolder: number;

  @OneToMany('File', 'folder')
  files: Relation<File>[];

  @CreateDateColumn({ name: 'created_at' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt: Date;
}