Files
negareh-api/src/modules/product/entities/product.entity.ts
T
2026-01-24 15:36:07 +03:30

43 lines
1006 B
TypeScript

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