This commit is contained in:
2025-12-15 11:15:08 +03:30
parent 9d677622f2
commit b776f2b83a
12 changed files with 80 additions and 60 deletions
+8 -4
View File
@@ -1,4 +1,4 @@
import { Cascade, Collection, Entity, Index, ManyToOne, OneToMany, Property } from '@mikro-orm/core';
import { Cascade, Collection, Entity, Index, ManyToOne, OneToMany, Property, OneToOne } from '@mikro-orm/core';
import { Category } from './category.entity';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../../modules/restaurants/entities/restaurant.entity';
@@ -14,13 +14,17 @@ export class Food extends BaseEntity {
restaurant: Restaurant;
@ManyToOne(() => Category)
category!: Category;
category: Category;
@OneToMany(() => Review, review => review.food, { cascade: [Cascade.ALL], orphanRemoval: true })
reviews = new Collection<Review>(this);
@OneToMany(() => Inventory, inventory => inventory.food, { cascade: [Cascade.ALL], orphanRemoval: true })
inventory = new Collection<Inventory>(this);
@OneToOne(() => Inventory, inventory => inventory.food, {
nullable: true,
cascade: [Cascade.ALL],
orphanRemoval: true,
})
inventory?: Inventory;
@Property({ nullable: true })
title?: string;
@@ -44,9 +44,6 @@ export class FoodService {
noon: rest.noon ?? false,
dinner: rest.dinner ?? false,
desc: rest.desc,
// pickup/stock
stock: rest.stock ?? 0,
stockDefault: rest.stockDefault ?? 0,
isActive: rest.isActive ?? true,
inPlaceServe: rest.inPlaceServe ?? false,
pickupServe: rest.pickupServe ?? false,