nodejs Mysql如何使用不同的数据库?

即时通讯新的nodejs,我做了两个不同的模型,当他们初始化我想用不同的数据库来获取数据这里是连接代码:

try { connection = mysql.createConnection({ host: this.config.host, user: this.config.user, password: this.config.password, database: this.config.database }); } catch (errorMessage) { logger.error('Error connecting to MySQL database on ' + this.config.database); } connection.connect(function(err){ /** * Connection needs some time to "get ready?" */ setTimeout(function() { if(err){ deferred.reject(err); } else { logger.info('Connected to database' + this.config); this.connection = connection; deferred.resolve(); } }, 1000 ); }); 

初始化函数:

 this.init = function(){ var deferred = Q.defer(); this.connect() .then(fun1) .then(fun2) .then(function(){ deferred.resolve(); },function(err){ deferred.reject(err); }); return deferred.promise; }; 

这是单身职能(我认为它没用):

 myclass.getInstance = function(){ if(this.instance === null){ this.instance = new myclass(); this.instance.init().then(function(){ this.connection.end(); }, function(error){ process.exit(); }); } return this.instance; } 

这些代码使用两种不同的模式,当一个获取数据的其他用户的旧连接实例(不同的数据库),我该如何解决?