Perform New Updates on a Document Using model.findOneAndUpdate()

Perform New Updates on a Document Using model.findOneAndUpdate()
0

#1

What is the problem here?

var findAndUpdate = function(personName, doc) {
var ageToSet = 20;

//console.log("person name : ", personName);
Person.findOneAndUpdate(
{“name”:personName},
{$set: {“age”: ageToSet}},
{new : true},
function(err, doc){
if(err){
console.log(“Something wrong when updating record!”);
}else{
console.log(doc)
}
})};