mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-22 02:12:40 +01:00
typeorm inverse relations of guild relations
This commit is contained in:
parent
27bcef502c
commit
2f48212e6e
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -327,6 +327,7 @@ export class Member extends BaseClassWithoutId {
|
||||
id: guild_id,
|
||||
},
|
||||
relations: PublicGuildRelations,
|
||||
relationLoadStrategy: "query",
|
||||
});
|
||||
|
||||
const memberCount = await Member.count({ where: { guild_id } });
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user