import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; import { BaseEntity } from '../../../common/entities/base.entity'; import { Category } from './category.entity'; import { Attribute } from './attribute.entity'; @Entity({ tableName: 'products' }) export class Product extends BaseEntity { @ManyToOne(() => Category) category: Category @OneToMany(() => Attribute, (attr) => attr.product) attributes = new Collection(this) @PrimaryKey({ type: 'bigint', autoincrement: true }) id: bigint @Property() title: string; @Property({ type: 'string' }) desc: string @Property({ type: 'json' }) quantities: number[] // @Property() // prepareTime: number; @Property({ type: 'text', nullable: true }) linkUrl?: string; @Property({ type: 'boolean', default: true }) isActive: boolean = true; @Property({ type: 'json', nullable: true }) images?: string[]; @Property({ type: 'int' }) order?: number | null }