import { Collection, Entity, ManyToOne, OneToMany, 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 { @Property({ primary: true }) id: bigint @ManyToOne(() => Category) category: Category @OneToMany(() => Attribute, (attr) => attr.productId) attributes = new Collection(this) @Property() title: string; @Property({ type: 'json' }) desc: string[] @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 }