Im trying to increase a value of an object by another value of an object using mongoose library.
Im getting a type cast error becuase it just identifies Resources.Gold as a number but does not find Workers.Efficiency.Mine so it counts it as a String.
Schema:
Resources: {
Gold: Nuber
}
Workers: {
Efficiency: {
Mine: Number
}
}
Update code:
schema.updateMany({}, {
$inc: {
"Resources.Gold": "Workers.Efficiency.Mine"
}
}, function(err, response) {
if(err) console.log(err);
else console.log(response);
});