1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-21 10:11:34 +02: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 {
Schema,
model,
Types,
Document
} from "mongoose";
import { Schema, model, Types, Document } from "mongoose";
import db from "../util/Database";
import {
PublicUser,
User,
UserModel,
PublicUserProjection
} from "./User";
import {
Guild, GuildModel
} from "./Guild";
import { PublicUser, User, UserModel, PublicUserProjection } from "./User";
import { Guild, GuildModel } from "./Guild";
export interface Template extends Document {
id: string;
code: string;
name: string;
description ? : string;
usage_count ? : number;
description?: string;
usage_count?: number;
creator_id: string;
creator: User;
created_at: Date;
@ -45,9 +33,9 @@ TemplateSchema.virtual("creator", {
ref: UserModel,
localField: "creator_id",
foreignField: "id",
justOne: false,
justOne: true,
autopopulate: {
select: PublicUserProjection
select: PublicUserProjection,
},
});
@ -55,9 +43,9 @@ TemplateSchema.virtual("serialized_source_guild", {
ref: GuildModel,
localField: "source_guild_id",
foreignField: "id",
justOne: false,
justOne: true,
autopopulate: true,
});
// @ts-ignore
export const TemplateModel = db.model < Template > ("Template", TemplateSchema, "templates");
export const TemplateModel = db.model<Template>("Template", TemplateSchema, "templates");