init
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { Entity, Index, ManyToOne, Property, Unique, Enum } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Food } from '../../foods/entities/food.entity';
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
import { Order } from 'src/modules/orders/entities/order.entity';
|
||||
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';
|
||||
import { ReviewStatus } from '../enums/review-status.enum';
|
||||
|
||||
@Entity({ tableName: 'reviews' })
|
||||
@Unique({ properties: ['order', 'food', 'user'] })
|
||||
@Index({ properties: ['food', 'status'] })
|
||||
@Index({ properties: ['user'] })
|
||||
@Index({ properties: ['order'] })
|
||||
export class Review extends BaseEntity {
|
||||
@ManyToOne(() => Order)
|
||||
order: Order;
|
||||
|
||||
@ManyToOne(() => Food)
|
||||
food: Food;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
user: User;
|
||||
|
||||
@Property({ type: 'text', nullable: true })
|
||||
comment?: string;
|
||||
|
||||
@Property({ type: 'int', nullable: false })
|
||||
rating: number = 0;
|
||||
|
||||
@Property({ type: 'json', nullable: true })
|
||||
positivePoints?: PositivePoint[];
|
||||
|
||||
@Property({ type: 'json', nullable: true })
|
||||
negativePoints?: NegativePoint[];
|
||||
|
||||
@Enum(() => ReviewStatus)
|
||||
@Property({ type: 'string', default: ReviewStatus.PENDING })
|
||||
status: ReviewStatus = ReviewStatus.PENDING;
|
||||
}
|
||||
Reference in New Issue
Block a user