Solution to Find, Edit and SAVE with mongoose

var findEditThenSave = function(personId, done) {
  var foodToAdd = 'hamburger';

  Person.findById({_id: personId}) 
  .then(function(person) {
    person.favoriteFoods.push(foodToAdd);

    person.save(function(err, people) {
      
    if(err) return console.log(err);
    
  done(null, people);
    
 
 });

  })
};

Link to the challenge:
https://www.freecodecamp.org/learn/apis-and-microservices/mongodb-and-mongoose/perform-classic-updates-by-running-find-edit-then-save

Hello there.

What worked for me on these challenges, when I got stuck was to clear my database, go to the first lesson, and resubmit the link, going through each lesson concurrently.

Hope this helps

1 Like

Thank you for the advise. I actually do it now when I encounter some weird errors.