Packages.findOneAndUpdate(
{filter},
{$set:{$inc:{reviews:1}},
rating:4},
{new:true,
upsert:true,
multi:true},
function(err, found){
if(!err){
console.log("updated")
}else{
console.log(err)
}
})
Only rating is getting changed and reviews is not incremented at all. Both reviews and rating is of same type i.e Number.
And I'm getting "updated" message in console.
Apply $inc without $set:
Packages.findOneAndUpdate({filter}, {
$set: { rating: 4 },
$inc: { reviews: 1 }
}, {
new: true,
upsert: true,
multi: true
});