I do not understand the reason why this is not working
const findEditThenSave = (personId, done) => {
Person.findById(personId,function(err,data){
data["favoriteFoods"].push("hamburger")
data.save()
if(err){
return done(err)
}
done(null,data)
})
};
It’s really difficult to determine that without the error message generated by the code or the rest of the code that goes with this. Post a link to your repl so that the code can be debugged.
1 Like
https://replit.com/@AaronArgotte/boilerplate-mongomongoose#myApp.js
You really just need to follow the exercise instructions explicitly. Remember, .save()
gets a callback and pay attention to the part about markModified()
.
Also, your repl was missing the code you originally posted. Start by adding logging of the err
and data
in your findById
callback.
1 Like
I am getting this error now:
No matching document found for id “6412f5d5f65f7a077282420d” version 0 modifiedPaths “favoriteFoods, edited-field”