mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
updated invite model
This commit is contained in:
parent
c5c2af70a5
commit
2d7e6a5081
@ -1,5 +1,8 @@
|
||||
import { Schema, Document, Types } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
import { ChannelModel } from "./Channel";
|
||||
import { UserModel } from "./User";
|
||||
import { GuildModel } from "./Guild";
|
||||
|
||||
export interface Invite extends Document {
|
||||
code: string;
|
||||
@ -33,5 +36,62 @@ export const InviteSchema = new Schema({
|
||||
target_user_type: Number,
|
||||
});
|
||||
|
||||
InviteSchema.virtual("channel", {
|
||||
ref: ChannelModel,
|
||||
localField: "channel_id",
|
||||
foreignField: "id",
|
||||
justOne: true,
|
||||
autopopulate: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
type: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
InviteSchema.virtual("inviter", {
|
||||
ref: UserModel,
|
||||
localField: "inviter_id",
|
||||
foreignField: "id",
|
||||
justOne: true,
|
||||
autopopulate: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
avatar: true,
|
||||
discriminater: true,
|
||||
public_flags: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
InviteSchema.virtual("guild", {
|
||||
ref: GuildModel,
|
||||
localField: "guild_id",
|
||||
foreignField: "id",
|
||||
justOne: true,
|
||||
autopopulate: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
splash: true,
|
||||
banner: true,
|
||||
description: true,
|
||||
icon: true,
|
||||
features: true,
|
||||
verification_level: true,
|
||||
vanity_url_code: true,
|
||||
welcome_screen: true,
|
||||
nsfw: true,
|
||||
|
||||
// TODO: hide the following entries:
|
||||
// channels: false,
|
||||
// roles: false,
|
||||
// emojis: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
export const InviteModel = db.model<Invite>("Invite", InviteSchema, "invites");
|
||||
|
Loading…
Reference in New Issue
Block a user