import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import { NewsletterConfigEnum } from "../../enums/newsletterConfigEnum"; import { communicationType } from "./communicationType"; @Entity() export class newsletterConfig { @PrimaryColumn() comTypeId: number; @Column({ type: "varchar", length: "255", transformer: { to(value: NewsletterConfigEnum) { return value.toString(); }, from(value: string) { return NewsletterConfigEnum[value as keyof typeof NewsletterConfigEnum]; }, }, }) config: NewsletterConfigEnum; @ManyToOne(() => communicationType, { nullable: false, onDelete: "CASCADE", onUpdate: "RESTRICT", cascade: ["insert"], }) comType: communicationType; }