mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-12-04 12:13:59 +01:00
Moving loop counter to inside of the sql select, and adding an extra abort stage.
This commit is contained in:
@@ -14,9 +14,13 @@ global.schema = JSON.parse(sql_schema);
|
|||||||
let loopCount = 0;
|
let loopCount = 0;
|
||||||
let updatedCount = 0;
|
let updatedCount = 0;
|
||||||
global.schema.forEach(function(entry){
|
global.schema.forEach(function(entry){
|
||||||
loopCount += 1;
|
|
||||||
global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){
|
global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){
|
||||||
|
loopCount += 1;
|
||||||
if (rows.length > 0){
|
if (rows.length > 0){
|
||||||
|
if(loopCount === global.schema.length){
|
||||||
|
console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!");
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updatedCount += 1;
|
updatedCount += 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user