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