From c924194b4956faae82e19a892660dbb9c800d8ff Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sun, 26 Feb 2017 10:51:28 -0800 Subject: [PATCH] Don't call callbacks so early. --- sql_sync/sql_sync.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sql_sync/sql_sync.js b/sql_sync/sql_sync.js index 6306b48..e1f5f5b 100644 --- a/sql_sync/sql_sync.js +++ b/sql_sync/sql_sync.js @@ -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!");