From 4c34797915359fa7e2028449e76d0bfd9fbeaa39 Mon Sep 17 00:00:00 2001 From: Noah Zalev Date: Thu, 22 Apr 2021 17:14:31 -0400 Subject: [PATCH] Include dbname in mysql/mariadb connectionObj --- db.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/db.js b/db.js index 07e2eae1..ebe640e1 100644 --- a/db.js +++ b/db.js @@ -439,13 +439,24 @@ module.exports.CreateDB = function (parent, func) { } if (parent.args.mariadb || parent.args.mysql) { + var connectinArgs = (parent.args.mariadb) ? parent.args.mariadb : parent.args.mysql; + var connectionObject = { + 'host': connectinArgs.host, + 'port': connectinArgs.port, + 'user': connectinArgs.user, + 'password': connectinArgs.password, + 'connectionLimit': null, + 'database': null + }; + if (connectinArgs.connectionLimit != null) connectionObject.connectionLimit = connectinArgs.connectionLimit; + connectionObject.database = (connectinArgs.database != null) ? connectinArgs.database : 'meshcentral'; if (parent.args.mariadb) { // Use MariaDB obj.databaseType = 4; - Datastore = require('mariadb').createPool(parent.args.mariadb); + Datastore = require('mariadb').createPool(connectionObject); } else if (parent.args.mysql) { // Use MySQL - Datastore = require('mysql').createConnection(parent.args.mysql); + Datastore = require('mysql').createConnection(connectionObject); obj.databaseType = 5; } //sqlDbQuery('DROP DATABASE MeshCentral', null, function (err, docs) { console.log('DROP'); }); return;