const shipSchema = new mongoose.Schema({
shipName: {
type: String,
required: [true, 'A ship name is required.'],
maxlength: [60, 'That ship name is too long, please try again.'],
unique: [true, 'Ship name already exists.'],
},
shipPhoto: {
type: String,
default: 'default.jpg',
},
});
In the example code above, I would like for the default shipPhoto name to be the shipName string noted above, appended with “.jpg”. Is there a way for me to do this? I’m just not sure what the syntax would look like. So, for example, if shipName is “DisneyWish”, I would like for the default shipPhoto name to be “DisneyWish.jpg”. Is that possible?