import { Place } from 'src/place/entities/place.entity';
import { User } from 'src/user/entities/user.entity';
import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Visited {
  @PrimaryGeneratedColumn()
  idVisited: number;

  @OneToOne(() => Place, (place) => place.idPlace, { eager: true })
  @JoinColumn({ name: 'place' })
  place: Place;

  @ManyToOne(() => User, (user) => user.email)
  @JoinColumn({ name: 'user' })
  user: User;

  @Column({ nullable: false })
  rating: number;

  @Column({ nullable: true, default: () => 'CURRENT_TIMESTAMP' })
  date: Date;
}
