Don't call callbacks so early.

This commit is contained in:
Alexander Blair
2017-02-26 10:51:28 -08:00
parent 81a05a64d1
commit c924194b49
+3 -5
View File
@@ -14,16 +14,14 @@ global.schema = JSON.parse(sql_schema);
let loopCount = 0;
let updatedCount = 0;
async.eachSeries(global.schema, function(entry, callback){
async.eachSeries(global.schema, function(entry){
global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){
loopCount += 1;
if (rows.length > 0){
callback();
return;
}
updatedCount += 1;
global.mysql.query("INSERT INTO config (module, item, item_value, item_type, Item_desc) VALUES (?, ?, ?, ?, ?)", [entry.module, entry.item, entry.item_value, entry.item_type, entry.Item_desc]).then(function(){
callback();
});
global.mysql.query("INSERT INTO config (module, item, item_value, item_type, Item_desc) VALUES (?, ?, ?, ?, ?)", [entry.module, entry.item, entry.item_value, entry.item_type, entry.Item_desc]);
});
}, function(){
console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!");