MongoDB and Mongoose - Perform New Updates on a Document Using model.findOneAndUpdate()

const findAndUpdate = (personName, done) => {
  const ageToSet = 20;
  Person.findOneAndUpdate(
    { name: personName },
    { age: ageToSet },
    { new: true },
    function (err, updatedDoc) {
      if (err) return console.log(err);
      done(null, updatedDoc);
    },
  );
};

I’m pretty sure this should work, after a few tries i asked chatgpt and it said the same, my connection to mongodb is working and my Person is defined properly, but the tests say:
findOneAndUpdate an item should succeed
Any ideas?

// Even after i now copied and pasted the solution for this one staight from the get a hint page it still doesn’t want to pass

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0

Challenge Information:

MongoDB and Mongoose - Perform New Updates on a Document Using model.findOneAndUpdate()

Does it make sense to return a console.log()? Instead, what should be returned?

I suppose it doesn’t really, I’ve just been adding those for some made-up error handling, but I don’t think it has anything to do with the tests not passing, does it?

Now i’ve logged the returned document and it does actually return it correctly, with the age updated

POST
Searching for person with name: Dorian Gray
(node:803) DeprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `useFindAndModify` option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#findandmodify
Found and updated: {
  favoriteFoods: [ 'chicken salad' ],
  _id: 68629e9b53bc2a091111f2bf,
  name: 'Dorian Gray',
  age: 20,
  __v: 0
}

so I’m really lost why does it not pass the freecodecamp tests

How did you handle errors for the functions you did before this one?