My test schema with the mongoose in nodejs contains the following fields:
testschema = mongoose.Schema({
name:{
type:String,
required:true,
unique:true
},
image:{
type:String,
required:true
},
category:{
type:String
},
});
I want to make the category field in my schema as optional and if the user didn't provide any value to that optional field then it should be set to blank by default. How can I make the category field optional?