1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 13:14:06 +01:00
server/dist/models/Guild.js

87 lines
2.8 KiB
JavaScript
Raw Normal View History

2021-02-05 22:01:01 +01:00
"use strict";
2021-02-16 21:16:56 +01:00
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
2021-02-05 22:01:01 +01:00
Object.defineProperty(exports, "__esModule", { value: true });
2021-02-13 14:15:59 +01:00
exports.GuildModel = exports.GuildSchema = void 0;
const mongoose_1 = require("mongoose");
2021-02-16 21:16:56 +01:00
const Database_1 = __importDefault(require("../util/Database"));
2021-04-06 03:56:19 +02:00
const Channel_1 = require("./Channel");
const Emoji_1 = require("./Emoji");
const Member_1 = require("./Member");
const Role_1 = require("./Role");
2021-02-13 14:15:59 +01:00
exports.GuildSchema = new mongoose_1.Schema({
2021-04-06 18:01:49 +02:00
id: { type: String, required: true },
afk_channel_id: String,
2021-02-13 14:15:59 +01:00
afk_timeout: Number,
2021-04-06 18:01:49 +02:00
application_id: String,
2021-02-13 14:15:59 +01:00
banner: String,
default_message_notifications: Number,
description: String,
discovery_splash: String,
explicit_content_filter: Number,
features: { type: [String], default: [] },
icon: String,
large: Boolean,
max_members: { type: Number, default: 100000 },
max_presences: Number,
max_video_channel_users: { type: Number, default: 25 },
member_count: Number,
presence_count: Number,
mfa_level: Number,
name: { type: String, required: true },
2021-04-06 18:01:49 +02:00
owner_id: { type: String, required: true },
2021-02-13 14:15:59 +01:00
preferred_locale: String,
premium_subscription_count: Number,
premium_tier: Number,
2021-04-06 18:01:49 +02:00
public_updates_channel_id: String,
2021-02-13 14:15:59 +01:00
region: String,
2021-04-06 18:01:49 +02:00
rules_channel_id: String,
2021-02-13 14:15:59 +01:00
splash: String,
system_channel_flags: Number,
2021-04-06 18:01:49 +02:00
system_channel_id: String,
2021-02-13 14:15:59 +01:00
unavailable: Boolean,
vanity_url_code: String,
verification_level: Number,
voice_states: { type: [Object], default: [] },
welcome_screen: { type: [Object], default: [] },
2021-04-06 18:01:49 +02:00
widget_channel_id: String,
2021-02-13 14:15:59 +01:00
widget_enabled: Boolean,
});
2021-04-06 03:56:19 +02:00
exports.GuildSchema.virtual("channels", {
ref: Channel_1.ChannelModel,
localField: "id",
foreignField: "guild_id",
justOne: false,
});
exports.GuildSchema.virtual("roles", {
ref: Role_1.RoleModel,
localField: "id",
foreignField: "guild_id",
justOne: false,
});
// nested populate is needed for member users: https://gist.github.com/yangsu/5312204
exports.GuildSchema.virtual("members", {
ref: Member_1.MemberModel,
localField: "id",
foreignField: "member_id",
justOne: false,
});
exports.GuildSchema.virtual("emojis", {
ref: Emoji_1.EmojiModel,
localField: "id",
foreignField: "guild_id",
justOne: false,
});
exports.GuildSchema.virtual("joined_at", {
ref: Member_1.MemberModel,
localField: "id",
foreignField: "guild_id",
justOne: true,
}).get((member, virtual, doc) => {
console.log("get", member, this);
return member.joined_at;
});
2021-02-16 21:16:56 +01:00
// @ts-ignore
exports.GuildModel = Database_1.default.model("Guild", exports.GuildSchema, "guilds");
2021-02-05 22:01:01 +01:00
//# sourceMappingURL=Guild.js.map