Files
negareh-api/src/modules/product/entities/product.entity.ts
T
2026-01-13 18:19:51 +03:30

40 lines
912 B
TypeScript

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<Attribute>(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
}