import { Entity, ManyToOne, Index, Property, Unique } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { User } from './user.entity';
import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity';

@Entity({ tableName: 'user_restuarant' })
@Index({ properties: ['restaurant'] })
@Unique({ properties: ['user', 'restaurant'] })
export class UserRestaurant extends BaseEntity {
  @ManyToOne(() => User)
  user!: User;

  @ManyToOne(() => Restaurant)
  restaurant!: Restaurant;

  @Property({ type: 'integer' })
  orderCount!: number;

  @Property({ type: 'integer' })
  totalOrderAmount!: number;

}
