Trying to model a relationship between collections by embedding documents but when validating in the schema and setting "required" to True, here comes the err
once I comment the required in genre object in movies schema the problem is solved but I want the validation
const Movie = mongoose.model(
'Movies',
new mongoose.Schema({
title: {
type: String,
required: true,
trim: true,
minlength: 1,
maxlength: 255
},
numberInStock: {
type: Number,
required: true,
min: 0,
max: 255
},
dailyRentalRate: {
type: Number,
required: true,
min: 0,
max: 255
},
genre: genreSchema
required: true
})
);
const genreSchema = new mongoose.Schema({
name: {
type: String,
required: true,
minlength: 5,
maxlength: 50
}
});
TypeError: Invalid schema configuration: True
is not a valid type at path required