const mongoose = require("mongoose"); const Schema = mongoose.Schema; const CampaignSchema = new Schema({ name: {type: String, required: true}, description: {type: String}, color: {type: String}, createdBy: { type: Schema.Types.ObjectId, ref: 'User', required: true }, date: { type: Date, default: Date.now}, settings: { type: Object }, foundryWorldId: { type: String, unique: true, sparse: true }, foundryWorldTitle: { type: String }, foundrySystem: { type: String }, foundrySyncTokenHash: { type: String, select: false }, // Discord server ("guild") this campaign is linked to. A campaign serves // at most one guild, and a guild selects one campaign. discordGuildId: { type: String, index: true } }); module.exports = mongoose.model('Campaign', CampaignSchema);