summary refs log tree commit diff
path: root/util/src/entities
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-30 12:15:06 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-30 12:15:06 +0200
commit4abc758991d3f92a6404f269770fb92f5375d1e4 (patch)
tree925932613c1632e82d74202ef32277ae3e8e94c5 /util/src/entities
parent:zap: only local rate limit to prevent to much pressure on the database (diff)
downloadserver-4abc758991d3f92a6404f269770fb92f5375d1e4.tar.xz
:construction: typeorm
Diffstat (limited to 'util/src/entities')
-rw-r--r--util/src/entities/BaseClass.ts3
-rw-r--r--util/src/entities/Emoji.ts2
-rw-r--r--util/src/entities/Guild.ts24
-rw-r--r--util/src/entities/Member.ts6
-rw-r--r--util/src/entities/Role.ts4
5 files changed, 20 insertions, 19 deletions
diff --git a/util/src/entities/BaseClass.ts b/util/src/entities/BaseClass.ts
index 31338ff6..63ce5836 100644
--- a/util/src/entities/BaseClass.ts
+++ b/util/src/entities/BaseClass.ts
@@ -51,7 +51,8 @@ export class BaseClass extends BaseEntity {
 			if (setter) {
 				setter.call(this, props[key]);
 			} else {
-				Object.defineProperty(this, key, { value: props[key] });
+				// @ts-ignore
+				this[key] = props[key];
 			}
 		}
 	}
diff --git a/util/src/entities/Emoji.ts b/util/src/entities/Emoji.ts
index 0686d476..4c0fccd3 100644
--- a/util/src/entities/Emoji.ts
+++ b/util/src/entities/Emoji.ts
@@ -15,7 +15,7 @@ export class Emoji extends BaseClass {
 	guild_id: string;
 
 	@JoinColumn({ name: "guild_id" })
-	@ManyToOne(() => Guild, (guild: Guild) => guild.id)
+	@ManyToOne(() => Guild, (guild: Guild) => guild.emojis)
 	guild: Guild;
 
 	@Column()
diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts
index e6a93824..3e7e8917 100644
--- a/util/src/entities/Guild.ts
+++ b/util/src/entities/Guild.ts
@@ -1,4 +1,4 @@
-import { Column, Entity, JoinColumn, ManyToMany, ManyToOne, OneToOne, RelationId } from "typeorm";
+import { Column, Entity, JoinColumn, ManyToMany, ManyToOne, OneToMany, OneToOne, RelationId } from "typeorm";
 import { BaseClass } from "./BaseClass";
 import { Channel } from "./Channel";
 import { Emoji } from "./Emoji";
@@ -68,35 +68,35 @@ export class Guild extends BaseClass {
 	member_ids: string[];
 
 	@JoinColumn({ name: "member_ids" })
-	@ManyToMany(() => Member, (member: Member) => member.id)
+	@OneToMany(() => Member, (member: Member) => member.guild)
 	members: Member[];
 
 	@RelationId((guild: Guild) => guild.roles)
 	role_ids: string[];
 
 	@JoinColumn({ name: "role_ids" })
-	@ManyToMany(() => Role, (role: Role) => role.id)
+	@OneToMany(() => Role, (role: Role) => role.guild)
 	roles: Role[];
 
 	@RelationId((guild: Guild) => guild.channels)
 	channel_ids: string[];
 
 	@JoinColumn({ name: "channel_ids" })
-	@ManyToMany(() => Channel, (channel: Channel) => channel.id)
+	@OneToMany(() => Channel, (channel: Channel) => channel.guild)
 	channels: Channel[];
 
 	@RelationId((guild: Guild) => guild.emojis)
 	emoji_ids: string[];
 
 	@JoinColumn({ name: "emoji_ids" })
-	@ManyToMany(() => Emoji, (emoji: Emoji) => emoji.id)
+	@OneToMany(() => Emoji, (emoji: Emoji) => emoji.guild)
 	emojis: Emoji[];
 
 	@RelationId((guild: Guild) => guild.voice_states)
 	voice_state_ids: string[];
 
 	@JoinColumn({ name: "voice_state_ids" })
-	@ManyToMany(() => VoiceState, (voicestate: VoiceState) => voicestate.id)
+	@OneToMany(() => VoiceState, (voicestate: VoiceState) => voicestate.guild)
 	voice_states: VoiceState[];
 
 	@Column({ nullable: true })
@@ -109,7 +109,7 @@ export class Guild extends BaseClass {
 	owner_id: string;
 
 	@JoinColumn({ name: "owner_id" })
-	@ManyToOne(() => User, (user: User) => user.id)
+	@OneToOne(() => User)
 	owner: User;
 
 	@Column({ nullable: true })
@@ -125,14 +125,14 @@ export class Guild extends BaseClass {
 	public_updates_channel_id: string;
 
 	@JoinColumn({ name: "public_updates_channel_id" })
-	@ManyToOne(() => Channel, (channel: Channel) => channel.id)
+	@OneToOne(() => Channel, (channel: Channel) => channel.id)
 	public_updates_channel?: Channel;
 
 	@RelationId((guild: Guild) => guild.rules_channel)
 	rules_channel_id?: string;
 
 	@JoinColumn({ name: "rules_channel_id" })
-	@ManyToOne(() => Channel, (channel: Channel) => channel.id)
+	@OneToOne(() => Channel, (channel: Channel) => channel.id)
 	rules_channel?: string;
 
 	@Column({ nullable: true })
@@ -145,7 +145,7 @@ export class Guild extends BaseClass {
 	system_channel_id?: string;
 
 	@JoinColumn({ name: "system_channel_id" })
-	@ManyToMany(() => Channel, (channel: Channel) => channel.id)
+	@OneToOne(() => Channel, (channel: Channel) => channel.id)
 	system_channel?: Channel;
 
 	@Column({ nullable: true })
@@ -158,7 +158,7 @@ export class Guild extends BaseClass {
 	vanity_url_code?: string;
 
 	@JoinColumn({ name: "vanity_url_code" })
-	@ManyToOne(() => Invite)
+	@OneToOne(() => Invite)
 	vanity_url?: Invite;
 
 	@Column({ nullable: true })
@@ -180,7 +180,7 @@ export class Guild extends BaseClass {
 	widget_channel_id?: string;
 
 	@JoinColumn({ name: "widget_channel_id" })
-	@ManyToOne(() => Channel, (channel: Channel) => channel.id)
+	@OneToOne(() => Channel, (channel: Channel) => channel.id)
 	widget_channel?: Channel;
 
 	@Column({ nullable: true })
diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts
index 5b588d70..c5d289ef 100644
--- a/util/src/entities/Member.ts
+++ b/util/src/entities/Member.ts
@@ -1,6 +1,6 @@
 import { PublicUser, User } from "./User";
 import { BaseClass } from "./BaseClass";
-import { Column, Entity, JoinColumn, ManyToMany, ManyToOne, RelationId } from "typeorm";
+import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, RelationId } from "typeorm";
 import { Guild } from "./Guild";
 import { Config, emitEvent } from "../util";
 import {
@@ -26,7 +26,7 @@ export class Member extends BaseClass {
 	guild_id: string;
 
 	@JoinColumn({ name: "guild_id" })
-	@ManyToOne(() => Guild, (guild: Guild) => guild.id)
+	@ManyToOne(() => Guild, (guild: Guild) => guild.members)
 	guild: Guild;
 
 	@Column({ nullable: true })
@@ -35,7 +35,7 @@ export class Member extends BaseClass {
 	@RelationId((member: Member) => member.roles)
 	role_ids: string[];
 
-	@JoinColumn({ name: "role_ids" })
+	@JoinTable()
 	@ManyToMany(() => Role)
 	roles: Role[];
 
diff --git a/util/src/entities/Role.ts b/util/src/entities/Role.ts
index ddae7e40..be8c731d 100644
--- a/util/src/entities/Role.ts
+++ b/util/src/entities/Role.ts
@@ -27,8 +27,8 @@ export class Role extends BaseClass {
 	@Column()
 	name: string;
 
-	@Column({ type: "bigint" })
-	permissions: bigint;
+	@Column()
+	permissions: string;
 
 	@Column()
 	position: number;