single connection config

This commit is contained in:
Jan Prochazka
2022-12-25 17:52:59 +01:00
parent a6fa116b5e
commit 54278f6276
3 changed files with 24 additions and 3 deletions

View File

@@ -1,12 +1,13 @@
DEVMODE=1 DEVMODE=1
CONNECTIONS=mysql CONNECTIONS=mysql
SINGLE_CONNECTION=mysql
LABEL_mysql=MySql localhost LABEL_mysql=MySql localhost
SERVER_mysql=localhost SERVER_mysql=localhost
# USER_mysql=root USER_mysql=root
PORT_mysql=3306 PORT_mysql=3306
# PASSWORD_mysql=Pwd2020Db PASSWORD_mysql=Pwd2020Db
ENGINE_mysql=mysql@dbgate-plugin-mysql ENGINE_mysql=mysql@dbgate-plugin-mysql
# PASSWORD_MODE_mysql=askPassword # PASSWORD_MODE_mysql=askPassword
PASSWORD_MODE_mysql=askUser # PASSWORD_MODE_mysql=askUser

View File

@@ -39,6 +39,7 @@ module.exports = {
return { return {
runAsPortal: !!connections.portalConnections, runAsPortal: !!connections.portalConnections,
singleDatabase: connections.singleDatabase, singleDatabase: connections.singleDatabase,
singleConnection: connections.singleConnection,
// hideAppEditor: !!process.env.HIDE_APP_EDITOR, // hideAppEditor: !!process.env.HIDE_APP_EDITOR,
allowShellConnection: platformInfo.allowShellConnection, allowShellConnection: platformInfo.allowShellConnection,
allowShellScripting: platformInfo.allowShellScripting, allowShellScripting: platformInfo.allowShellScripting,

View File

@@ -157,12 +157,31 @@ function getSingleDatabase() {
return null; return null;
} }
function getSingleConnection() {
if (getSingleDatabase()) return null;
if (process.env.SINGLE_CONNECTION) {
// @ts-ignore
const connection = portalConnections.find(x => x._id == process.env.SINGLE_CONNECTION);
if (connection) {
return connection;
}
}
// @ts-ignore
const arg0 = (portalConnections || []).find(x => x._id == 'argv');
if (arg0) {
return arg0;
}
return null;
}
const singleDatabase = getSingleDatabase(); const singleDatabase = getSingleDatabase();
const singleConnection = getSingleConnection();
module.exports = { module.exports = {
datastore: null, datastore: null,
opened: [], opened: [],
singleDatabase, singleDatabase,
singleConnection,
portalConnections, portalConnections,
async _init() { async _init() {