food review
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user