Moving loop counter to inside of the sql select, and adding an extra abort stage.

This commit is contained in:
Alexander Blair
2017-02-11 11:52:30 -08:00
parent 9977bae7b4
commit 4af3a38355
+5 -1
View File
@@ -14,9 +14,13 @@ global.schema = JSON.parse(sql_schema);
let loopCount = 0;
let updatedCount = 0;
global.schema.forEach(function(entry){
loopCount += 1;
global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){
loopCount += 1;
if (rows.length > 0){
if(loopCount === global.schema.length){
console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!");
process.exit();
}
return;
}
updatedCount += 1;