mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-27 06:33:15 -05:00
use mysql2 package to support mysql8 (#5427)
Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
This commit is contained in:
parent
58580beb96
commit
e20a585b3a
8
db.js
8
db.js
@ -768,13 +768,13 @@ module.exports.CreateDB = function (parent, func) {
|
||||
} else if (parent.args.mysql) {
|
||||
// Use MySQL
|
||||
obj.databaseType = 5;
|
||||
var tempDatastore = require('mysql').createPool(connectionObject);
|
||||
var tempDatastore = require('mysql2').createPool(connectionObject);
|
||||
tempDatastore.query('CREATE DATABASE IF NOT EXISTS ' + dbname, function (error) {
|
||||
if (error != null) {
|
||||
console.log('Auto-create database failed: ' + error);
|
||||
}
|
||||
connectionObject.database = dbname;
|
||||
Datastore = require('mysql').createPool(connectionObject);
|
||||
Datastore = require('mysql2').createPool(connectionObject);
|
||||
createTablesIfNotExist(dbname);
|
||||
});
|
||||
setTimeout(function () { tempDatastore.end(); }, 2000);
|
||||
@ -1244,7 +1244,7 @@ module.exports.CreateDB = function (parent, func) {
|
||||
var docs = [];
|
||||
for (var i in results) {
|
||||
if (results[i].doc) {
|
||||
docs.push(JSON.parse(results[i].doc));
|
||||
docs.push(results[i].doc);
|
||||
} else if ((results.length == 1) && (results[i]['COUNT(doc)'] != null)) {
|
||||
// This is a SELECT COUNT() operation
|
||||
docs = results[i]['COUNT(doc)'];
|
||||
@ -1314,7 +1314,7 @@ module.exports.CreateDB = function (parent, func) {
|
||||
.catch(function (err) { if (func) { try { func(err); } catch (ex) { console.log(ex); } } });
|
||||
} else if ((obj.databaseType == 5) || (obj.databaseType == 6)) { // MySQL
|
||||
var Promises = [];
|
||||
for (var i in queries) { if (typeof queries[i] == 'string') { Promises.push(Datastore.query(queries[i])); } else { Promises.push(Datastore.query(queries[i][0], queries[i][1])); } }
|
||||
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])); } }
|
||||
Promise.all(Promises)
|
||||
.then(function (error, results, fields) { 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); } } });
|
||||
|
@ -4018,7 +4018,7 @@ function mainStart() {
|
||||
if (sessionRecording == true) { modules.push('image-size'); } // Need to get the remote desktop JPEG sizes to index the recodring file.
|
||||
if (config.letsencrypt != null) { modules.push('acme-client@4.2.5'); } // Add acme-client module. We need to force v4.2.4 or higher since olver versions using SHA-1 which is no longer supported by Let's Encrypt.
|
||||
if (config.settings.mqtt != null) { modules.push('aedes@0.39.0'); } // Add MQTT Modules
|
||||
if (config.settings.mysql != null) { modules.push('mysql'); } // Add MySQL.
|
||||
if (config.settings.mysql != null) { modules.push('mysql2'); } // Add MySQL.
|
||||
//if (config.settings.mysql != null) { modules.push('@mysql/xdevapi'); } // Add MySQL, official driver (https://dev.mysql.com/doc/dev/connector-nodejs/8.0/)
|
||||
if (config.settings.mongodb != null) { modules.push('mongodb@4.13.0'); modules.push('saslprep'); } // Add MongoDB, official driver.
|
||||
if (config.settings.postgres != null) { modules.push('pg@8.7.1'); modules.push('pgtools@0.3.2'); } // Add Postgres, Postgres driver.
|
||||
|
Loading…
x
Reference in New Issue
Block a user