无法在mongoose中连接多个数据库

时间:2014-04-16 16:51:12

标签: node.js mongodb mongoose

我想使用mongodb使用createConnection而不是mongoose的两个数据库。

exports.mongooseMaster = mongoose.createConnection('mongodb://192.168.2.10:27017/Master', function (err, res) {
   if (err) {
      console.log ('ERROR connecting to: remote Master ' + err);
  } else {
      console.log ('Successfully connected to: remote Master');
  }
});

// Connect to Database
exports.mongoosetime = mongoose.createConnection('mongodb://192.168.2.10:27017/Planner2', function (err, res) {
if (err) {
      console.log ('ERROR connecting to: remote Planner2 ' + err);
  } else {
      console.log ('Successfully connected to: remote Planner2');
  };
});

当我执行此代码时,我看到只有Planner2数据库创建的不是Master数据库。但是我在控制台中获得了这些内容

Successfully connected to: remote Master
Successfully connected to: remote Planner2

会出现什么问题?

0 个答案:

没有答案