attribute
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user