summaryrefslogtreecommitdiff
path: root/src/models/entities/drive-folder.ts
blob: a80d075855a24861241a4b3f958e7c13db19ce52 (plain)
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
import { JoinColumn, ManyToOne, Entity, PrimaryColumn, Index, Column } from 'typeorm';
import { User } from './user';
import { id } from '../id';

@Entity()
export class DriveFolder {
	@PrimaryColumn(id())
	public id: string;

	@Index()
	@Column('timestamp with time zone', {
		comment: 'The created date of the DriveFolder.'
	})
	public createdAt: Date;

	@Column('varchar', {
		length: 128,
		comment: 'The name of the DriveFolder.'
	})
	public name: string;

	@Index()
	@Column({
		...id(),
		nullable: true,
		comment: 'The owner ID.'
	})
	public userId: User['id'] | null;

	@ManyToOne(type => User, {
		onDelete: 'CASCADE'
	})
	@JoinColumn()
	public user: User | null;

	@Index()
	@Column({
		...id(),
		nullable: true,
		comment: 'The parent folder ID. If null, it means the DriveFolder is located in root.'
	})
	public parentId: DriveFolder['id'] | null;

	@ManyToOne(type => DriveFolder, {
		onDelete: 'SET NULL'
	})
	@JoinColumn()
	public parent: DriveFolder | null;
}