import {
  Column,
  CreateDateColumn,
  Entity,
  Index,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { EntityHelper } from 'src/utils/entity-helper';
import { Team } from 'src/teams/entities/team.entity';
import { NOTIFICATION_EVENT } from '../model/notification-event.type';

@Entity()
export class Notification extends EntityHelper {
  @PrimaryGeneratedColumn()
  id: number;

  @Index('IDX_notification_team_id')
  @ManyToOne(() => Team, { eager: false })
  team: Team;

  @Column()
  event: NOTIFICATION_EVENT;

  @Column()
  actorUserId: number;

  @Column({ type: 'text' })
  payload: string;

  @CreateDateColumn()
  createdAt: Date;
}
