이것이 왜 저에게 효과가 있는지 알 수없는 것 같습니다. 부하중첩 된 비동기/기다리는 노드
module.exports = async function() {
try {
await load();
} catch (ex) {
console.log(ex);
logger.error(ex);
}
};
async function load() {
return await new Promise((resolve, reject) => {
TableImport.findAll().then((tables) => {
for (let table of tables) {
await loadData(table.fileName, table.tableName);
}
resolve();
}).catch(function (err) {
reject(err);
})
})
};
async function loadData(location, tableName) {
return await new Promise(function (resolve, reject) {
var currentFile = path.resolve(__dirname + '/../fdb/' + location);
sequelize.query("LOAD DATA LOCAL INFILE '" + currentFile.replace('/', '//').replace(/\\/g, '\\\\') + "' INTO TABLE " + tableName + " FIELDS TERMINATED BY '|'").then(function() {
resolve(tableName);
}).catch(function (ex) {
reject();
});
});
};
AWAIT 진술 실패 : 나는 아이로드 프로세스상의 AWAIT을 수행하는 상위 기능을 가지고 ... 차례로 LOAD 프로세스는 다른 그래서 기본적으로 같은 ...라는 LOADDATA을 기다리고 호출
await loadData (table.fileName, table.tableName); SyntaxError : 예기치 않은 식별자
분명히 비동기의 범위에 대해 이해하지 못합니다!
'return await ...'할 이유가 없습니다. 그냥 약속을 되 찾으십시오. 또한, 기존 약속들에 대한 새로운 약속을 포장하는 약속의 안티 패턴을 피해야한다. – jfriend00