const mongoose = require('mongoose'); const eventInviteSchema = new mongoose.Schema( { email: { type: String, required: true, lowercase: true, trim: true }, event: { type: mongoose.Schema.Types.ObjectId, ref: 'Event', required: true, index: true }, organization: { type: mongoose.Schema.Types.ObjectId, ref: 'Organization', required: true, index: true }, invitedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, token: { type: String, required: true, unique: true, index: true }, sessionIds: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Session' }], eventRole: { type: String, default: 'Viewer' }, expiresAt: { type: Date, required: true }, status: { type: String, enum: ['pending', 'accepted', 'cancelled'], default: 'pending' }, }, { timestamps: true } ); eventInviteSchema.index({ event: 1, email: 1, status: 1 }); module.exports = mongoose.model('EventInvite', eventInviteSchema);