✨ BanSchema
This commit is contained in:
parent
1357796da3
commit
e3f5d7060b
@ -1,5 +1,6 @@
|
|||||||
import { Schema, model, Types, Document } from "mongoose";
|
import { Schema, model, Types, Document } from "mongoose";
|
||||||
import db from "../util/Database";
|
import db from "../util/Database";
|
||||||
|
import { PublicUserProjection, UserModel } from "./User";
|
||||||
|
|
||||||
export interface Ban extends Document {
|
export interface Ban extends Document {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
@ -17,5 +18,13 @@ export const BanSchema = new Schema({
|
|||||||
ip: String, // ? Should we store this in here, or in the UserModel?
|
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
|
// @ts-ignore
|
||||||
export const BanModel = db.model<Ban>("Ban", BanSchema, "bans");
|
export const BanModel = db.model<Ban>("Ban", BanSchema, "bans");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user