【发布时间】:2016-07-29 14:35:56
【问题描述】:
我正在尝试对要更新的字段是数字类型的特定记录执行简单的 upsert 操作。 我使用它的记录 ID 获取记录,只是 +1 数字字段并再次保存它,但由于某种原因,它不会从日志中看到增量/更新
代码是:
customer.findById(customerObject.id, function(err, objectResult){
console.log(objectResult.imageIndex);
if(!objectResult.imageIndex){
objectResult.imageIndex = 1;
}
else{
var index = objectResult.imageIndex;
objectResult.imageIndex = index++;
console.log(objectResult.imageIndex);
}
customer.upsert(objectResult, function(err, response){});
})
console.log 都会显示相同的值。为什么它不会增加和更新,代码有什么问题吗?
【问题讨论】:
-
登录 `typeof(objectResult.imageIndex)' 会得到什么?
-
它的印刷品'数字'
标签: javascript node.js mongodb loopbackjs strongloop