attribute
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
import { Entity, Enum, ManyToOne, OneToMany, Property } from '@mikro-orm/core';
|
||||
import { 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';
|
||||
|
||||
@Entity({ tableName: 'attributes' })
|
||||
export class Attribute extends BaseEntity {
|
||||
@ManyToOne(()=>Product)
|
||||
@ManyToOne(() => Product)
|
||||
product: Product
|
||||
|
||||
@ManyToOne(() => Attribute, { nullable: true })
|
||||
parent?: Attribute | null
|
||||
|
||||
|
||||
@OneToMany(() => Attribute, (c) => c.parent)
|
||||
children?: Attribute[]
|
||||
|
||||
@Property({ primary: true })
|
||||
id: bigint;
|
||||
@PrimaryKey({ type: 'bigint', autoincrement: true })
|
||||
id: number;
|
||||
|
||||
@Property()
|
||||
name: string;
|
||||
|
||||
@Enum()
|
||||
@Enum(() => AttributeType)
|
||||
type: AttributeType;
|
||||
|
||||
@Property({ type: 'boolean', default: false })
|
||||
|
||||
Reference in New Issue
Block a user