diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util/entities/Channel.ts | 5 | ||||
-rw-r--r-- | src/util/entities/Emoji.ts | 2 | ||||
-rw-r--r-- | src/util/entities/Invite.ts | 2 | ||||
-rw-r--r-- | src/util/entities/Member.ts | 1 | ||||
-rw-r--r-- | src/util/entities/Role.ts | 4 | ||||
-rw-r--r-- | src/util/entities/Sticker.ts | 4 | ||||
-rw-r--r-- | src/util/entities/VoiceState.ts | 4 |
7 files changed, 12 insertions, 10 deletions
diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 6268d735..9f7041d4 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -97,10 +97,11 @@ export class Channel extends BaseClass { guild_id?: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.channels, { onDelete: "CASCADE", + nullable: true, }) - guild: Guild; + guild?: Guild; @Column({ nullable: true }) @RelationId((channel: Channel) => channel.parent) diff --git a/src/util/entities/Emoji.ts b/src/util/entities/Emoji.ts index 0bc2f423..4d851698 100644 --- a/src/util/entities/Emoji.ts +++ b/src/util/entities/Emoji.ts @@ -33,7 +33,7 @@ export class Emoji extends BaseClass { guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.emojis, { onDelete: "CASCADE", }) guild: Guild; diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts index 7970c4f0..f7e54fbe 100644 --- a/src/util/entities/Invite.ts +++ b/src/util/entities/Invite.ts @@ -53,7 +53,7 @@ export class Invite extends BaseClassWithoutId { guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.invites, { onDelete: "CASCADE", }) guild: Guild; diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index d305e4f5..0535313e 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -327,6 +327,7 @@ export class Member extends BaseClassWithoutId { id: guild_id, }, relations: PublicGuildRelations, + relationLoadStrategy: "query", }); const memberCount = await Member.count({ where: { guild_id } }); diff --git a/src/util/entities/Role.ts b/src/util/entities/Role.ts index 9a601f31..e8e5feda 100644 --- a/src/util/entities/Role.ts +++ b/src/util/entities/Role.ts @@ -23,12 +23,12 @@ import { Guild } from "./Guild"; @Entity("roles") export class Role extends BaseClass { - @Column({ nullable: true }) + @Column() @RelationId((role: Role) => role.guild) guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.roles, { onDelete: "CASCADE", }) guild: Guild; diff --git a/src/util/entities/Sticker.ts b/src/util/entities/Sticker.ts index cd07e65a..e9294f92 100644 --- a/src/util/entities/Sticker.ts +++ b/src/util/entities/Sticker.ts @@ -17,9 +17,9 @@ */ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; -import { User } from "./User"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; +import { User } from "./User"; export enum StickerType { STANDARD = 1, @@ -62,7 +62,7 @@ export class Sticker extends BaseClass { guild_id?: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.stickers, { onDelete: "CASCADE", }) guild?: Guild; diff --git a/src/util/entities/VoiceState.ts b/src/util/entities/VoiceState.ts index b291c4d3..84b0ca71 100644 --- a/src/util/entities/VoiceState.ts +++ b/src/util/entities/VoiceState.ts @@ -20,8 +20,8 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Channel } from "./Channel"; import { Guild } from "./Guild"; -import { User } from "./User"; import { Member } from "./Member"; +import { User } from "./User"; //https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex @Entity("voice_states") @@ -31,7 +31,7 @@ export class VoiceState extends BaseClass { guild_id: string; @JoinColumn({ name: "guild_id" }) - @ManyToOne(() => Guild, { + @ManyToOne(() => Guild, (guild) => guild.voice_states, { onDelete: "CASCADE", }) guild?: Guild; |