Let me share my customized user schema below.
var userSchema=mongoose.Schema({
//name:{type:String},
username: {type:String, required:true, unique:true},
password: {type:String, required:true},
habit: {type:Object, required:true}
});
However, I encountered an issue where the habit field is not being saved when a new user (newbie) is added to MongoDB.
var newbie=new User({
username:username,
password:password,
habit:{}
});
console.log(newbie);
Upon checking console.log(newbie)
, the result shows "{ _id: ~~~????, username: 'babo', password: '1234' }" without the habit field. How can I properly include the habit attribute?