I want to have the flight number variable unique. By unique, I mean it shouldn't be the same like another one that has been created before.
const flightSchema = new Schema ({ FlightNumber: { type: String, required: true, }, DepartureTime: { type: Date, required: true } }}
CodePudding user response:
Add unique: true
, like FlightNumber: { type: String, required: true, unique: true }
CodePudding user response:
add unique: true
I hope it helps you