food review

This commit is contained in:
2025-12-08 12:04:50 +03:30
parent aededf6da9
commit 1771b000b4
4 changed files with 67 additions and 12 deletions
+5 -1
View File
@@ -1,7 +1,8 @@
import { Entity, ManyToOne, Property } from '@mikro-orm/core';
import { Cascade, Collection, Entity, ManyToOne, OneToMany, Property } from '@mikro-orm/core';
import { Category } from './category.entity';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../../modules/restaurants/entities/restaurant.entity';
import { Review } from 'src/modules/review/entities/review.entity';
@Entity({ tableName: 'foods' })
export class Food extends BaseEntity {
@@ -11,6 +12,9 @@ export class Food extends BaseEntity {
@ManyToOne(() => Category)
category!: Category;
@OneToMany(() => Review, review => review.food, { cascade: [Cascade.ALL], orphanRemoval: true })
reviews = new Collection<Review>(this);
@Property({ nullable: true })
title?: string;