码迷,mamicode.com
首页 > 其他好文 > 详细

node 同步修改(递归)多条数据

时间:2017-11-08 14:48:35      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:数据   some   this   dex   main   index   ons   ocs   res   


var elems = [];
for(let [index, elem] of point.entries()) {
elems[index] = elem;
}

function executeFunc(rightpoints_docs, elems, count, sum) {
if(count == sum) {
return res({
code: 0,
msg: ‘过期订单已退积分‘,
data: {}
})
} else {
let filter = {
cardnumber: elems[count].cardnumber
};
Card.readByCardnumber(filter, (err, Cardnumberpoints) => {
var thisRcarpoints = Cardnumberpoints[0].points;
var remainrpoint = parseInt(thisRcarpoints) + parseInt(rightpoints_docs[0].point);
const ToUpdate = {
points: remainrpoint,
}
let filterr1 = {
cardnumber: elems[count].cardnumber
};
//添加权益卡积分详情成功时更新权益卡表中的权益卡总权益积分
Card.updatesomeByRCardnumber(filterr1, ToUpdate, (err, card) => {
count++;
executeFunc(rightpoints_docs, elems, count, sum);

});

});

}
}
//同步调用
var len = elems.length;

//rightpoints_docs   未定义对象数组

let  rightpoints_docs=[{point:200}]
executeFunc(rightpoints_docs, elems, 0, len);

node 同步修改(递归)多条数据

标签:数据   some   this   dex   main   index   ons   ocs   res   

原文地址:http://www.cnblogs.com/luoliangfei/p/7803552.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!