var articleFinish;
async.series({
one: function(callback) {
async.eachOf(set, function(tags, index, callback) {
Article.findById(articleId).exec(function(err, article) {
article.weibos[2].text = 'aa'; //success
article.weibos[2].tags = 'aaa'; //success
article.weibos[index].text = tags; //can't set value for next 'article'
article.weibos[index].tags = tags; //can't set value for next 'article'
articleFinish = article;
callback();
});
}, function(err) {
if (err) console.error(err.message);
callback(null, 3);
});
},
two: function(callback) {
Article.findById(articleId).exec(function(err, article) {
article = articleFinish;//can't get value when use the last two statement.
article.save(function(err) {});
});
}
}, function(err, results) {
res.send(results);
});
我想通过全局变量
设置最后article
的值
我该怎么办?