0
A
回答
1
可以使用async
模塊,具體這種方法async.each
https://github.com/caolan/async#each
https://www.npmjs.com/package/async這裏的故宮包
增加了一個小例子(而不是我的if
你想在你的數據庫檢查)
var tests = ['a', 'b'];
async.each(tests, function(test, callback) {
if(test === 'c') {
return callback('We cannot have a c')
}
return callback();
}, function(err){
// if any of the file processing produced an error, err would equal that error
if(err) {
// One of the iterations produced an error.
// All processing will now stop.
console.log('C was found');
} else {
console.log('All Tests are ok');
}
});
相關問題
- 1. 的NodeJS FileReads同步到異步
- 2. NodeJs中的異步函數
- 3. nodejs中的異步foreach
- 4. 異步NodeJS
- 5. NodeJS中的異步Vs同步
- 6. Nodejs異步執行
- 7. Nodejs回調異步
- 8. Nodejs異步混淆
- 9. 應用異步nodejs
- 10. NodeJS流異步foreachlimit
- 11. NodeJs - 異步/待機異步/等待
- 12. 異步的NodeJS的同時
- 13. 異步回調的NodeJS
- 14. 異步方法的NodeJS
- 15. 在NodeJS中使用異步響應的異步調用
- 16. 異步查詢到數據庫在nodeJS
- 17. 等待NodeJS中的異步方法
- 18. Nodejs中異步函數的返回值
- 19. nodejs中的異步和遞歸
- 20. nodejs中的異步串聯字符串
- 21. 處理nodejs中的異步回調
- 22. nodejs中的多個異步mongo請求
- 23. nodejs函數中的異步混亂
- 24. nodejs循環中的異步函數
- 25. nodejs中的異步和Q承諾
- 26. 處理NodeJS異步行爲
- 27. Nodejs異步上升問題
- 28. 異步並等待nodejs
- 29. 異步nodejs模塊導出
- 30. NodeJS mysql異步查詢