1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00

🐛 fix template

This commit is contained in:
Flam3rboy 2021-08-12 16:45:31 +02:00
parent ca432f99b9
commit 11450b6d39

View File

@ -1,26 +1,14 @@
import { import { Schema, model, Types, Document } from "mongoose";
Schema,
model,
Types,
Document
} from "mongoose";
import db from "../util/Database"; import db from "../util/Database";
import { import { PublicUser, User, UserModel, PublicUserProjection } from "./User";
PublicUser, import { Guild, GuildModel } from "./Guild";
User,
UserModel,
PublicUserProjection
} from "./User";
import {
Guild, GuildModel
} from "./Guild";
export interface Template extends Document { export interface Template extends Document {
id: string; id: string;
code: string; code: string;
name: string; name: string;
description ? : string; description?: string;
usage_count ? : number; usage_count?: number;
creator_id: string; creator_id: string;
creator: User; creator: User;
created_at: Date; created_at: Date;
@ -45,9 +33,9 @@ TemplateSchema.virtual("creator", {
ref: UserModel, ref: UserModel,
localField: "creator_id", localField: "creator_id",
foreignField: "id", foreignField: "id",
justOne: false, justOne: true,
autopopulate: { autopopulate: {
select: PublicUserProjection select: PublicUserProjection,
}, },
}); });
@ -55,9 +43,9 @@ TemplateSchema.virtual("serialized_source_guild", {
ref: GuildModel, ref: GuildModel,
localField: "source_guild_id", localField: "source_guild_id",
foreignField: "id", foreignField: "id",
justOne: false, justOne: true,
autopopulate: true, autopopulate: true,
}); });
// @ts-ignore // @ts-ignore
export const TemplateModel = db.model < Template > ("Template", TemplateSchema, "templates"); export const TemplateModel = db.model<Template>("Template", TemplateSchema, "templates");