mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 20:31:45 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { User } from '~/user/entities';
|
|
import { NotificationChannel, NotificationScope, NotificationStatus } from '../enums';
|
|
|
|
@Entity('notifications')
|
|
export class Notification {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column('varchar', { name: 'title' })
|
|
title!: string;
|
|
|
|
@Column('varchar', { name: 'message' })
|
|
message!: string;
|
|
|
|
@Column('varchar', { name: 'recipient', nullable: true })
|
|
recipient?: string | null;
|
|
|
|
@Column('varchar', { name: 'scope' })
|
|
scope!: NotificationScope;
|
|
|
|
@Column('varchar', { name: 'status', nullable: true })
|
|
status!: NotificationStatus | null;
|
|
|
|
@Column('varchar', { name: 'channel' })
|
|
channel!: NotificationChannel;
|
|
|
|
@Column('uuid', { name: 'user_id', nullable: true })
|
|
userId!: string;
|
|
|
|
@ManyToOne(() => User, (user) => user.notifications, { onDelete: 'CASCADE', nullable: true })
|
|
@JoinColumn({ name: 'user_id' })
|
|
user!: User;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
}
|