forked from FoundKeyGang/FoundKey
Johann150
94d1cf75aa
Minor adjustment: The 'name' columns have the same max length. Major adjustment: Rename both columns to be "parentId" and update all references of this name in the backend. API parameters are not changed, since that would be an unnecessary breaking change.
50 lines
987 B
TypeScript
50 lines
987 B
TypeScript
import { JoinColumn, ManyToOne, Entity, PrimaryColumn, Index, Column } from 'typeorm';
|
|
import { id } from '../id.js';
|
|
import { User } from './user.js';
|
|
|
|
@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: 256,
|
|
comment: 'The name of the DriveFolder.',
|
|
})
|
|
public name: string;
|
|
|
|
@Index()
|
|
@Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: 'The owner ID.',
|
|
})
|
|
public userId: User['id'] | null;
|
|
|
|
@ManyToOne(() => 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(() => DriveFolder, {
|
|
onDelete: 'SET NULL',
|
|
})
|
|
@JoinColumn()
|
|
public parent: DriveFolder | null;
|
|
}
|