diff --git a/src/models/Ban.ts b/src/models/Ban.ts
index 27893029..2d1da4f0 100644
--- a/src/models/Ban.ts
+++ b/src/models/Ban.ts
@@ -1,5 +1,6 @@
import { Schema, model, Types, Document } from "mongoose";
import db from "../util/Database";
+import { PublicUserProjection, UserModel } from "./User";
export interface Ban extends Document {
user_id: string;
@@ -17,5 +18,13 @@ export const BanSchema = new Schema({
ip: String, // ? Should we store this in here, or in the UserModel?
});
+BanSchema.virtual("user", {
+ ref: UserModel,
+ localField: "id",
+ foreignField: "user_id",
+ justOne: true,
+ autopopulate: { select: PublicUserProjection },
+});
+
// @ts-ignore
export const BanModel = db.model<Ban>("Ban", BanSchema, "bans");
|