Files
dmenu-api/src/modules/foods/entities/category.entity.ts
T
2026-01-05 11:28:36 +03:30

28 lines
807 B
TypeScript

import { Entity, Index, Property, Collection, OneToMany, ManyToOne } from '@mikro-orm/core';
import { Food } from './food.entity';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity';
@Entity({ tableName: 'categories' })
@Index({ properties: ['restaurant', 'isActive'] })
@Index({ properties: ['isActive'] })
export class Category extends BaseEntity {
@Property()
title!: string;
@OneToMany(() => Food, food => food.category)
foods = new Collection<Food>(this);
@Property({ default: true })
isActive: boolean = true;
@ManyToOne(() => Restaurant)
restaurant!: Restaurant;
@Property({ nullable: true })
avatarUrl?: string;
@Property({ type: 'int', nullable: true })
order?: number;
}