For quite a long time I have used a db query to set the DB connection - this could be, for example, to connect to a user's company data which is in a separate DB to other companies. It has worked for PHP and Node but on a new project, using the latest modules it seems to have a different behaviour.
The user logs in and a query is run in Globals to find the company info - the dynamic DB connection is set to point to that user's company connection settings from that point on. Because it is in Globals it applies to all dynamic connections they run. Users can also be a user on more than one company so can switch and load different DB connection settings which then should be used by dynamic connections from that point.
Using 6.7.1 on NodeJS (stable) the dynamic connection is made but it seems that the setting used by the first connection are used for the entire service and not changed until the server is restarted. This means that they aren't really dynamic but allow data binding to some fixed value
Could the connection properties be evaluated on use and if different than previous, that connection is closed and a new one opened?
This is a sample DB connection file:
Which equates to this in code view:
{
"name": "dyn_db",
"module": "dbconnector",
"action": "connect",
"options": {
"client": "mysql2",
"connection": {
"host": "{{get_dbcreds.dba}}",
"port": 3306,
"user": "{{get_dbcreds.dbu}}",
"password": "{{get_dbcreds.dbpw}}",
"database": "{{get_dbcreds.dbn}}",
"charset": "utf8mb4",
"ssl": {
"rejectUnauthorized": false
}
}
},
"serverType": "node",
"fileName": "dyn_db.json"
}