1

I have two enterprises, and both have separate DBs. And when I select these enterprises through the drop-down, I want to change my DB connection with that option.

1
  • It depends on your database driver. I believe that most of them could give you multiple connection instances if you wish. Commented Jul 2, 2018 at 11:20

1 Answer 1

2
const conn = require('./connection.js'); // your path

 conn.changeUser({database : 'databasename'}, function(err) { 
     if (err) throw err; 
   });
Sign up to request clarification or add additional context in comments.

3 Comments

is this possible to username & password of db?
** yes you can do.** user: The name of the new user (defaults to the previous one). password: The password of the new user (defaults to the previous one). charset: The new charset (defaults to the previous one). database: The new database (defaults to the previous
Shubham can you please show you connection.js file, I am handling same thing with a bit different funtionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.