summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-22 22:54:45 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-22 22:54:45 +0200
commite3f5d7060bc147abd4cee67d1eb0b55064898cde (patch)
tree604a6cfd6adacb5315e3638f3477504bc4068f21
parent1.2.6 (diff)
downloadserver-e3f5d7060bc147abd4cee67d1eb0b55064898cde.tar.xz
:sparkles: BanSchema
-rw-r--r--src/models/Ban.ts9
1 files changed, 9 insertions, 0 deletions
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");