【发布时间】:2021-07-24 17:16:41
【问题描述】:
我正在尝试将 Punishment 架构导入我的 guild.js,但我不知道如何导入它。
如你所见,我有惩罚.js,但我需要将惩罚模式包含到 guild.js 中,因为它依赖于它
Punishments.js
const mongoose = require("mongoose");
const punishmentType = Object.freeze({
WARN: "Warn",
BAN: "Ban",
MUTE: "Mute",
});
const punishmentSchema = mongoose.Schema({
userId: String,
type: {
type: String,
enum: Object.values(punishmentType),
},
});
exports.punishmentSchema = punishmentSchema;
exports.Punishment = mongoose.model("Punishment", punishmentSchema);
Guild.js
const mongoose = require("mongoose");
const guild = mongoose.Schema({
id: String,
prefix: String,
punishments: [Punishment],
});
const Guild = mongoose.model("Guild", guild);
module.exports = Guild;
【问题讨论】:
标签: node.js mongodb mongoose discord.js