const flightSchema = new mongoose.Schema({
airline: {
type: String,
ref: Airline,
required: true,
},
pricing: {
adult: {type: Number, required: true },
child: {type: Number, required: false },
infant: {type: Number, required: false },
},
status : {
type: String,
enum: [‘SCHEDULED’, ‘DELAYED’, ‘CANCELLED’],
default: “SCHEDULED”
//SCHEDULED: Flight is on time and set to depart as planned.
//DELAYED: Used when there’s a delay; the admin might update this if departure or arrival times change.
//CANCELLED: Marks the flight as unavailable, preventing bookings or processing for that flight.
},
class : {
type: String,
required: true,
enum: [‘ECONOMY’, ‘BUSINESS’, ‘FIRST’],
default: “ECONOMY”,
},
pnrStatus: {
type : String,
required: true,
enum: [‘LIVE’, ‘WAITING FROM AIRLINE’]
},
pnr: {
type : String,
},
outboundFlight: {
flightNumber: { type: String, required: true },
departureAirport: { type: String, required: true },
departureTime: { type: String, required: true },
departureDate: { type: String, required: true },
arrivalAirport: { type: String, required: true },
arrivalTime: { type: String, required: true },
arrivalDate: { type: String, required: true },
cabinBaggage: { type: Number, required: true},
seatsAvailable: { type: Number, default: 0 },
},
returnFlight: {
flightNumber: { type: String, required: true },
departureAirport: { type: String, required: true },
departureTime: { type: String, required: true },
departureDate: { type: String, required: true },
arrivalAirport: { type: String, required: true },
arrivalTime: { type: String, required: true },
arrivalDate: { type: String, required: true },
cabinBaggage: { type: Number, required: true},
seatsAvailable: { type: Number, default: 0 },
},
},{timestamps: true}
);
okey, in here im thinking for example (a flight is available 20 days in a month) when user is adding tickets let them add for multiple dates so that the admin need not to add each day in frontend by creating new form submission for each dates…if the flight is runnning each day like wise the admin can add based on their data. so for that how to set model like that what other things needed to change and all