-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventPostModel.ts
More file actions
48 lines (38 loc) · 1.15 KB
/
EventPostModel.ts
File metadata and controls
48 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
Unique,
UpdateDateColumn,
} from "typeorm";
import { Uuid } from "../types";
import { PostModel } from "./PostModel";
import { EventTagModel } from "./EventTagModel";
export type EventPostSource = "user" | "similarity" | "nlp_context";
@Entity("eventPosts")
@Unique(["postId", "eventTagId"]) // Enforces one row per post per event, so ML layer can't insert another row if event already user-tagged
export class EventPostModel {
@PrimaryGeneratedColumn("uuid")
id: Uuid;
@Column()
postId: Uuid;
@ManyToOne(() => PostModel, { onDelete: "CASCADE" })
@JoinColumn({ name: "postId" })
post: PostModel;
@Column()
eventTagId: Uuid;
@ManyToOne(() => EventTagModel, { onDelete: "CASCADE" })
@JoinColumn({ name: "eventTagId" })
eventTag: EventTagModel;
@Column({ type: "varchar", length: 20 })
source: EventPostSource;
@Column({ type: "float", nullable: true, default: null })
relevanceScore: number | null;
@CreateDateColumn({ type: "timestamptz" })
createdAt: Date;
@UpdateDateColumn({ type: "timestamptz" })
updatedAt: Date;
}