File

lib/common/media/entity/media.entity.ts

Description

The entity stores media objects in itself

Index

Properties

Properties

code
Type : string
Decorators :
@Index({unique: true})
@Column('varchar', {nullable: true})
files
Type : MediaFileEntity[]
Decorators :
@OneToMany(undefined, f => f.media, {cascade: true})
id
Type : number
Decorators :
@PrimaryGeneratedColumn({zerofill: true})
metadata
Type : FileMetadataEntity
Decorators :
@OneToOne(undefined, t => t.id, {cascade: true, onDelete: 'CASCADE'})
@JoinColumn()
name
Type : LocalizedStringEntity[]
Decorators :
@ManyToMany(undefined, {cascade: true})
@JoinTable()
tsCreated
Type : Date
Decorators :
@Index()
@CreateDateColumn({name: 'ts_created', type: 'timestamp'})
type
Type : MediaTypeEntity
Decorators :
@ManyToOne(undefined, type => type.code)
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;
}

results matching ""

    No results matching ""