var totalAmount = rec.priceofdata;
var amountfor_user = rec.priceofdata;
var amountfor_dataseed = -totalAmount*0.30;
console.log("\n\n")
console.log(idOfUser);
console.log(totalAmount);
console.log(amountfor_user);
console.log(amountfor_dataseed);
// var amountfor_seller =
account.findOneAndUpdate({accountnumber:rec.creditcardnumber},{$inc:{currentamount:amountfor_user}},function(err,account){
if(err) console.log(err);
console.log(account);
//The Function mentioned below is not being
//recognized even tho it is exact same as the above one
//therefore i used .update, it works but has a little bug.
//it increments 4567789456452123's currentamount to amountfor_user instead of
// amountfor_dataseed
// account.findOneAndUpdate({accountnumber:4567789456452123},{$inc:{currentamount:-amountfor_user}},function(err,account){
account.update({accountnumber:4567789456452123},{$inc:{currentamount:amountfor_dataseed}},function(err,dataseedaccount){
if(err) console.log(err);
reciept.remove({_id:rec._id},function(err,removed){
if(err) console.log(err);
acessToken.remove({token:rec.token},function(err,remove){
if(err) console.log(err);
});
})
});
});
即使第一个正常工作,也无法识别 findOneAndUpdate
。其次,我将findOneAndUpdate
替换为update
,但是发生的问题是它更新了currentamount + = amountfor_user的值,而不是-amountfor_dataseed。