node 同步修改(递归)多条数据
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);