mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-15 04:21:51 +00:00
fix sql batch must use same connection from pool (#5469)
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
2117c19717
commit
c6ebcc6e8e
1 changed files with 8 additions and 5 deletions
9
db.js
9
db.js
|
@ -1313,11 +1313,14 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
})
|
})
|
||||||
.catch(function (err) { if (func) { try { func(err); } catch (ex) { console.log(ex); } } });
|
.catch(function (err) { if (func) { try { func(err); } catch (ex) { console.log(ex); } } });
|
||||||
} else if ((obj.databaseType == 5) || (obj.databaseType == 6)) { // MySQL
|
} else if ((obj.databaseType == 5) || (obj.databaseType == 6)) { // MySQL
|
||||||
|
Datastore.getConnection(function(err, connection) {
|
||||||
|
if (err) { if (func) { try { func(err); } catch (ex) { console.log(ex); } } return; }
|
||||||
var Promises = [];
|
var Promises = [];
|
||||||
for (var i in queries) { if (typeof queries[i] == 'string') { Promises.push(Datastore.promise().query(queries[i])); } else { Promises.push(Datastore.promise().query(queries[i][0], queries[i][1])); } }
|
for (var i in queries) { if (typeof queries[i] == 'string') { Promises.push(connection.promise().query(queries[i])); } else { Promises.push(connection.promise().query(queries[i][0], queries[i][1])); } }
|
||||||
Promise.all(Promises)
|
Promise.all(Promises)
|
||||||
.then(function (error, results, fields) { if (func) { try { func(error, results); } catch (ex) { console.log(ex); } } })
|
.then(function (error, results, fields) { connection.release(); if (func) { try { func(error, results); } catch (ex) { console.log(ex); } } })
|
||||||
.catch(function (error, results, fields) { if (func) { try { func(error); } catch (ex) { console.log(ex); } } });
|
.catch(function (error, results, fields) { connection.release(); if (func) { try { func(error); } catch (ex) { console.log(ex); } } });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue