import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { EntityHelper } from 'src/utils/entity-helper';
import { Notification } from './notification.entity';

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

  @Index('IDX_notification_recipient_notification_id')
  @ManyToOne(() => Notification, { onDelete: 'CASCADE' })
  notification: Notification;

  @Index('IDX_notification_recipient_user_id')
  @Column()
  userId: number;

  @Column({ default: false })
  read: boolean;

  @Column({ nullable: true })
  readAt: Date | null;
}
