summary refs log tree commit diff
path: root/util/src/entities/Webhook.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-26 20:48:09 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-26 20:48:09 +0200
commitdb3f5c0d1b5556e16c37704467b3599a6230be02 (patch)
treee74df1466e66900a284c65e270d56040d0dfde7e /util/src/entities/Webhook.ts
parent:bug: fix unit tests (diff)
downloadserver-db3f5c0d1b5556e16c37704467b3599a6230be02.tar.xz
:sparkles: use RelationId
Diffstat (limited to 'util/src/entities/Webhook.ts')
-rw-r--r--util/src/entities/Webhook.ts46
1 files changed, 35 insertions, 11 deletions
diff --git a/util/src/entities/Webhook.ts b/util/src/entities/Webhook.ts
index 54233638..dc929c18 100644
--- a/util/src/entities/Webhook.ts
+++ b/util/src/entities/Webhook.ts
@@ -1,5 +1,9 @@
-import { Column, Entity, JoinColumn } from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
+import { Application } from "./Application";
 import { BaseClass } from "./BaseClass";
+import { Channel } from "./Channel";
+import { Guild } from "./Guild";
+import { User } from "./User";
 
 export enum WebhookType {
 	Incoming = 1,
@@ -23,18 +27,38 @@ export class Webhook extends BaseClass {
 	@Column()
 	token?: string;
 
-	@JoinColumn()
-	guild?: string;
+	@RelationId((webhook: Webhook) => webhook.guild)
+	guild_id: string;
 
-	@JoinColumn()
-	channel: string;
+	@JoinColumn({ name: "guild_id" })
+	@ManyToOne(() => Guild, (guild: Guild) => guild.id)
+	guild: Guild;
 
-	@JoinColumn()
-	application?: string;
+	@RelationId((webhook: Webhook) => webhook.channel)
+	channel_id: string;
 
-	@JoinColumn()
-	user?: string;
+	@JoinColumn({ name: "channel_id" })
+	@ManyToOne(() => Channel, (channel: Channel) => channel.id)
+	channel: Channel;
 
-	@JoinColumn()
-	source_guild: string;
+	@RelationId((webhook: Webhook) => webhook.application)
+	application_id: string;
+
+	@JoinColumn({ name: "application_id" })
+	@ManyToOne(() => Application, (application: Application) => application.id)
+	application: Application;
+
+	@RelationId((webhook: Webhook) => webhook.user)
+	user_id: string;
+
+	@JoinColumn({ name: "user_id" })
+	@ManyToOne(() => User, (user: User) => user.id)
+	user: User;
+
+	@RelationId((webhook: Webhook) => webhook.guild)
+	source_guild_id: string;
+
+	@JoinColumn({ name: "source_guild_id" })
+	@ManyToOne(() => Guild, (guild: Guild) => guild.id)
+	source_guild: Guild;
 }