feat(notification): add entity
This commit is contained in:
88
src/entity/notification.ts
Normal file
88
src/entity/notification.ts
Normal file
@ -0,0 +1,88 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
CreateDateColumn,
|
||||
Index,
|
||||
} from "typeorm";
|
||||
|
||||
import { User } from "./users";
|
||||
|
||||
@Index("idx_notification_recipient_id", ["recipient_id"])
|
||||
@Index("idx_notification_sender_id", ["sender_id"])
|
||||
@Entity("notifications")
|
||||
export class Notification {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => User, { nullable: false, onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "recipient_id" })
|
||||
recipient: User;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
})
|
||||
type: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: false,
|
||||
})
|
||||
message: string;
|
||||
|
||||
@Column({
|
||||
type: "jsonb",
|
||||
nullable: true,
|
||||
})
|
||||
data: Record<string, unknown> | null;
|
||||
|
||||
@ManyToOne(() => User, { nullable: true, onDelete: "SET NULL" })
|
||||
@JoinColumn({ name: "sender_id" })
|
||||
sender: User | null;
|
||||
|
||||
@Column({
|
||||
type: "boolean",
|
||||
default: false,
|
||||
})
|
||||
is_read: boolean;
|
||||
|
||||
@Column({
|
||||
type: "timestamp",
|
||||
nullable: true,
|
||||
})
|
||||
read_at: Date | null;
|
||||
|
||||
@Column({
|
||||
type: "varchar",
|
||||
length: 10,
|
||||
nullable: true,
|
||||
})
|
||||
priority: string | null;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
nullable: true,
|
||||
})
|
||||
action_url: string | null;
|
||||
|
||||
@Column({
|
||||
type: "timestamp",
|
||||
nullable: true,
|
||||
})
|
||||
expires_at: Date | null;
|
||||
|
||||
@Column({
|
||||
type: "uuid",
|
||||
nullable: true,
|
||||
})
|
||||
batch_id: string | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true, length: 256 })
|
||||
created_by: string;
|
||||
}
|
||||
@ -53,6 +53,7 @@ export * from "../entity/subdistrict";
|
||||
export * from "../entity/ward";
|
||||
export * from "../entity/responsible_party_consent";
|
||||
export * from "../entity/foster_care_history";
|
||||
export * from "../entity/notification";
|
||||
|
||||
export * from "../types/public";
|
||||
export * from "../types/action";
|
||||
|
||||
Reference in New Issue
Block a user