lib/common/media/entity/media.entity.ts
The entity stores media objects in itself
Properties |
code |
Type : string
|
Decorators :
@Index({unique: true})
|
Defined in lib/common/media/entity/media.entity.ts:34
|
files |
Type : MediaFileEntity[]
|
Decorators :
@OneToMany(undefined, f => f.media, {cascade: true})
|
Defined in lib/common/media/entity/media.entity.ts:44
|
id |
Type : number
|
Decorators :
@PrimaryGeneratedColumn({zerofill: true})
|
Defined in lib/common/media/entity/media.entity.ts:30
|
metadata |
Type : FileMetadataEntity
|
Decorators :
@OneToOne(undefined, t => t.id, {cascade: true, onDelete: 'CASCADE'})
|
Defined in lib/common/media/entity/media.entity.ts:51
|
name |
Type : LocalizedStringEntity[]
|
Decorators :
@ManyToMany(undefined, {cascade: true})
|
Defined in lib/common/media/entity/media.entity.ts:38
|
tsCreated |
Type : Date
|
Decorators :
@Index()
|
Defined in lib/common/media/entity/media.entity.ts:55
|
type |
Type : MediaTypeEntity
|
Decorators :
@ManyToOne(undefined, type => type.code)
|
Defined in lib/common/media/entity/media.entity.ts:41
|
import {
Column,
CreateDateColumn,
Entity,
Index,
JoinColumn,
JoinTable,
ManyToMany,
ManyToOne,
OneToMany,
OneToOne,
PrimaryGeneratedColumn,
TableInheritance,
} from "typeorm";
import { MediaTypeEntity } from "./media-type.entity";
import { MediaFileEntity } from "./media-file.entity";
import { Media } from "../media.types";
import { LocalizedStringEntity } from "../../../shared/modules/locale/entity/localized-string.entity";
import { FileMetadataEntity } from "../../file/entity/file-metadata.entity";
/**
* The entity stores media objects in itself
*/
@Entity("medias")
@TableInheritance({
column: { type: "varchar", name: "class", nullable: true },
})
export class MediaEntity implements Media {
@PrimaryGeneratedColumn({ zerofill: true })
id: number;
@Index({ unique: true })
@Column("varchar", { nullable: true })
code: string;
@ManyToMany(() => LocalizedStringEntity, { cascade: true })
@JoinTable()
name: LocalizedStringEntity[];
@ManyToOne(() => MediaTypeEntity, (type) => type.code)
type: MediaTypeEntity;
@OneToMany(() => MediaFileEntity, (f) => f.media, { cascade: true })
files: MediaFileEntity[];
@OneToOne(() => FileMetadataEntity, (t) => t.id, {
cascade: true,
onDelete: "CASCADE",
})
@JoinColumn()
metadata: FileMetadataEntity;
@Index()
@CreateDateColumn({ name: "ts_created", type: "timestamp" })
tsCreated: Date;
}