// /components/waitlist/waitlistModel.js 'use strict'; const mongoose = require('mongoose'); const uniqueCodePlugin = require('../../utils/mongooseUniqueCodePlugin'); const waitlistSchema = new mongoose.Schema({ user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, index: true }, course: { type: mongoose.Schema.Types.ObjectId, ref: 'Course', required: true, index: true }, payment: { type: mongoose.Schema.Types.ObjectId, ref: 'Payment', index: true }, class: { type: mongoose.Schema.Types.ObjectId, ref: 'Class', default: null, index: true }, status: { type: String, enum: ['waiting', 'enrolled', 'cancelled', 'reverted'], default: 'waiting', index: true }, adminNotes: { type: [String], default: [] }, registeredAt: { type: Date, default: Date.now }, assignedAt: { type: Date, default: null }, isDeleted: { type: Boolean, default: false, index: true }, deletedAt: { type: Date, default: null } }, { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }); waitlistSchema.plugin(uniqueCodePlugin); module.exports = mongoose.model('Waitlist', waitlistSchema);