私は、更新するフィールドが数値型である特定のレコードに対して単純なupsert操作を実行しようとしています。 私はそのレコードid、ただ1番号フィールドを使用してレコードをフェッチして、もう一度それを保存しますが、何らかの理由でそれは文句を言わないの増分/更新シンプルなmongoオブジェクトupsertを使用してstrongloop
コードは、ログから見て:
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) 'をログインしたとき、あなたは何を得るのですか? –
そのプリント番号 ' – Firdous