This commit is contained in:
2026-01-28 16:33:30 +03:30
parent e7b5e96b5d
commit 4dc42aa676
10 changed files with 93 additions and 65 deletions
@@ -1,9 +1,7 @@
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { FieldOption } from './field-option.entity';
import { FieldType } from '../interface/print';
import { Section } from 'src/modules/print/entities/section.entity';
import { EntityType, FieldType } from '../interface/print';
import { BaseEntity } from 'src/common/entities/base.entity';
import { Product } from 'src/modules/product/entities/product.entity';
@Entity({ tableName: 'field' })
@@ -14,11 +12,13 @@ export class Field extends BaseEntity {
@OneToMany(() => FieldOption, (attrValue) => attrValue.field)
options = new Collection<FieldOption>(this)
@ManyToOne(() => Section, { nullable: true })
section?: Section
// Discriminator column
@Enum(() => EntityType) // Product , Print
entityType: EntityType;
@ManyToOne(() => Product, { nullable: true })
product?: Product
// Foreign key based on entityType
@Property({ type: 'bigint' })
entityId: bigint;
@Property()
name: string;