attribute values

This commit is contained in:
2026-01-16 20:23:15 +03:30
parent 8e3a2b0dec
commit 2ddf892793
6 changed files with 16 additions and 10 deletions
@@ -1,7 +1,8 @@
import { Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { AttributeType } from '../interface/product.interface';
import { Product } from './product.entity';
import { AttributeValue } from './attribute-value.entity';
@Entity({ tableName: 'attributes' })
export class Attribute extends BaseEntity {
@@ -12,7 +13,10 @@ export class Attribute extends BaseEntity {
parent?: Attribute | null
@OneToMany(() => Attribute, (c) => c.parent)
children?: Attribute[]
children=new Collection<Attribute>(this)
@OneToMany(() => AttributeValue, (attrValue) => attrValue.attribute)
values= new Collection<AttributeValue>(this)
@PrimaryKey({ type: 'bigint', autoincrement: true })
id: bigint;