attribute

This commit is contained in:
2026-01-15 20:37:28 +03:30
parent 7229931045
commit 17b4b30a3f
8 changed files with 226 additions and 5 deletions
@@ -1,4 +1,4 @@
import { Entity, Enum, ManyToOne, Property } from '@mikro-orm/core';
import { Entity, Enum, ManyToOne, OneToMany, Property } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { AttributeType } from '../interface/product.interface';
import { Product } from './product.entity';
@@ -8,6 +8,12 @@ export class Attribute extends BaseEntity {
@ManyToOne(()=>Product)
product: Product
@ManyToOne(() => Attribute, { nullable: true })
parent?: Attribute | null
@OneToMany(() => Attribute, (c) => c.parent)
children?: Attribute[]
@Property({ primary: true })
id: bigint;
@@ -20,4 +26,7 @@ export class Attribute extends BaseEntity {
@Property({ type: 'boolean', default: false })
isRequired: boolean = false;
@Property({ type: 'int', nullable: true })
order?: number;
}