node 同步修改(递归)多条数据
Posted atttitude
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
以上是关于node 同步修改(递归)多条数据的主要内容,如果未能解决你的问题,请参考以下文章