lib/common/file/entity/file.entity.ts
The entity stores data about uploaded files
Properties |
code |
Type : string
|
Decorators :
@Index({unique: true})
|
Defined in lib/common/file/entity/file.entity.ts:29
|
icon |
Type : MediaEntity
|
Decorators :
@ManyToOne(undefined, t => t.code)
|
Defined in lib/common/file/entity/file.entity.ts:44
|
id |
Type : number
|
Decorators :
@PrimaryGeneratedColumn({zerofill: true})
|
Defined in lib/common/file/entity/file.entity.ts:25
|
metadata |
Type : FileMetadataEntity
|
Decorators :
@OneToOne(undefined, t => t.id, {cascade: true, onDelete: 'CASCADE'})
|
Defined in lib/common/file/entity/file.entity.ts:54
|
name |
Type : string
|
Decorators :
@Column('varchar', {nullable: true})
|
Defined in lib/common/file/entity/file.entity.ts:32
|
path |
Type : string
|
Decorators :
@Column('varchar', {nullable: true})
|
Defined in lib/common/file/entity/file.entity.ts:35
|
preview |
Type : MediaEntity
|
Decorators :
@ManyToOne(undefined, t => t.code)
|
Defined in lib/common/file/entity/file.entity.ts:47
|
public |
Type : boolean
|
Decorators :
@Column('boolean', {default: false})
|
Defined in lib/common/file/entity/file.entity.ts:38
|
size |
Type : number
|
Decorators :
@Column('int', {nullable: true})
|
Defined in lib/common/file/entity/file.entity.ts:41
|
tsCreated |
Type : Date
|
Decorators :
@Index()
|
Defined in lib/common/file/entity/file.entity.ts:58
|
import {
Column,
CreateDateColumn,
Entity,
Index,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn,
TableInheritance,
} from "typeorm";
import { File } from "../file.types";
import { MediaEntity } from "../../media/entity/media.entity";
import { FileMetadataEntity } from "./file-metadata.entity";
/**
* The entity stores data about uploaded files
*/
@Entity("files")
@TableInheritance({
column: { type: "varchar", name: "class", nullable: true },
})
export class FileEntity implements File {
@PrimaryGeneratedColumn({ zerofill: true })
id: number;
@Index({ unique: true })
@Column("varchar", { nullable: true })
code: string;
@Column("varchar", { nullable: true })
name: string;
@Column("varchar", { nullable: true })
path: string;
@Column("boolean", { default: false })
public: boolean;
@Column("int", { nullable: true })
size: number;
@ManyToOne(() => MediaEntity, (t) => t.code)
icon: MediaEntity;
@ManyToOne(() => MediaEntity, (t) => t.code)
preview: MediaEntity;
@OneToOne(() => FileMetadataEntity, (t) => t.id, {
cascade: true,
onDelete: "CASCADE",
})
@JoinColumn()
metadata: FileMetadataEntity;
@Index()
@CreateDateColumn({ name: "ts_created", type: "timestamp" })
tsCreated: Date;
}