I am trying to insert a new field 'description' with a findOneAndUpdate statement using Mongoose js. It is not working. The code works fine when the field already exists and updates it with the given value. According to the Mongodb documentation $set should create this field automatically if it does not exist.
Any ideas appreciated.
Course.findOneAndUpdate({'_id': CourseId},{$set:{'description':courseDescription}},function(err, course) {
if (err)
res.jsonp({response:'err'});
res.jsonp(course);
});