Unsuccessfully updating Mongoose subdocument Unsuccessfully updating Mongoose subdocument mongoose mongoose

Unsuccessfully updating Mongoose subdocument


You shouldn't need the findOneAndUpdate, as you already have the linkedItem when you do

const linkedItem = item.linkedItems.id(linkedItemId);

So you could just set those properties and then use .save()

linkedItem.score = newAverageScore;linkedItem.currentNumberOfRatings = currentTotalNumberOfRatings;item.save(function(err, result){  console.log(err);  console.log(result);});