const mongoose = require("mongoose"); // Clear cache if (mongoose.models.Booking) { delete mongoose.models.Booking; } if (mongoose.connection.models.Booking) { delete mongoose.connection.models.Booking; } const bookingSchema = new mongoose.Schema( { hero: { title: { type: String, trim: true, maxlength: 80 }, backgroundImage: { type: String, trim: true, maxlength: 255 }, }, searchBar: { locationLabel: { type: String, trim: true, maxlength: 64 }, holidaySeasonLabel: { type: String, trim: true, maxlength: 64 }, searchButtonText: { type: String, trim: true, maxlength: 64 }, }, filterPanel: { title: { type: String, trim: true, maxlength: 80 }, priceTitle: { type: String, trim: true, maxlength: 64 }, priceLabel: { type: String, trim: true, maxlength: 64 }, pricePlaceholder: { type: String, trim: true, maxlength: 64 }, priceMin: Number, priceMax: Number, activitiesTitle: { type: String, trim: true, maxlength: 64 }, ageTitle: { type: String, trim: true, maxlength: 64 }, ageSelectPlaceholder: { type: String, trim: true, maxlength: 64 }, ageMin: Number, ageMax: Number, ratingTitle: { type: String, trim: true, maxlength: 64 }, ratingOptions: [ { value: { type: String, trim: true, maxlength: 48 }, label: { type: String, trim: true, maxlength: 64 }, }, ], resetButtonText: { type: String, trim: true, maxlength: 64 }, }, programs: [ { value: { type: String, trim: true, maxlength: 64 }, label: { type: String, trim: true, maxlength: 64 }, }, ], holidays: [ { value: { type: String, trim: true, maxlength: 64 }, label: { type: String, trim: true, maxlength: 64 }, }, ], locations: [ { value: { type: String, trim: true, maxlength: 64 }, label: { type: String, trim: true, maxlength: 64 }, }, ], camps: [ { name: { type: String, trim: true, maxlength: 120 }, price: Number, priceText: { type: String, trim: true, maxlength: 32 }, season: [String], age: [Number], locations: [String], image: { type: String, trim: true, maxlength: 255 }, link: { type: String, trim: true, maxlength: 255 }, program: { type: String, trim: true, maxlength: 80 }, rating: Number, }, ], // Configuration - Dùng Mixed type để chấp nhận bất kỳ structure nào configuration: mongoose.Schema.Types.Mixed, formSteps: [ { step: Number, title: String, sections: [ { id: String, fields: [mongoose.Schema.Types.Mixed], }, ], }, ], validation: mongoose.Schema.Types.Mixed, }, { timestamps: true, strict: false } ); module.exports = mongoose.model("Booking", bookingSchema);