diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/models/Guild.ts | 2 | ||||
-rw-r--r-- | src/models/Member.ts | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/models/Guild.ts b/src/models/Guild.ts index 8eb7533f..effc20ee 100644 --- a/src/models/Guild.ts +++ b/src/models/Guild.ts @@ -87,5 +87,7 @@ export const GuildSchema = new Schema({ widget_enabled: Boolean, }); +// GuildSchema.virtual + // @ts-ignore export const GuildModel = db.model<GuildDocument>("Guild", GuildSchema, "guilds"); diff --git a/src/models/Member.ts b/src/models/Member.ts index a377f54e..c177c6c9 100644 --- a/src/models/Member.ts +++ b/src/models/Member.ts @@ -1,5 +1,5 @@ -import { PublicUser } from "./User"; -import { Schema, model, Types, Document } from "mongoose"; +import { PublicUser, User, UserModel } from "./User"; +import { Schema, Types, Document } from "mongoose"; import db from "../util/Database"; export interface Member { @@ -13,6 +13,7 @@ export interface Member { mute: boolean; pending: boolean; settings: UserGuildSettings; + user?: User; } export interface MemberDocument extends Member, Document { @@ -74,9 +75,16 @@ export const MemberSchema = new Schema({ }, }); +MemberSchema.virtual("user", { + model: UserModel, + localField: "user", + foreignField: "id", +}); + // @ts-ignore export const MemberModel = db.model<MemberDocument>("Member", MemberSchema, "members"); +// @ts-ignore export interface PublicMember extends Omit<Member, "settings" | "id"> { user: PublicUser; } |