我正在尝试使用$ in数组来增加某个文档,.....首先,我必须在数组内查找一个项目,这是我的问题..当数组具有相同项目时,它不会增加该项目,像这样:
newFruits = ['orange','orange','orange'];
Fruits.find({{fruit: { $in : newFruits}}}, function(err, fruitDocs) {
for(let fruits of fruitDocs) {
fruits.value = fruits.value + 1
fruits .save(function(err) {});
}
});
示例文档:
fruit:orange,
value:0 //this should be 3 since the array is composed of 3 orange
//but when I try to increment it only increment once
fruit:apple,
value:0