mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
Don't call callbacks so early.
This commit is contained in:
@@ -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!");
|
||||
|
||||
Reference in New Issue
Block a user