diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-02-22 21:30:38 +0100 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-02-22 21:30:38 +0100 |
commit | 92a6c981ce12f4484509d0388cb1fba2a52b55c4 (patch) | |
tree | c73fc11423ee7cbcac066b15698793f13679e98e /src | |
parent | :wrench: build (diff) | |
download | server-92a6c981ce12f4484509d0388cb1fba2a52b55c4.tar.xz |
:sparkles: MemberModel add virtual user field
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; } |