【问题标题】:Two connections with mongoose in the same application. The second connection is to connect the first dependent在同一个应用程序中与 mongoose 的两个连接。第二个连接是连接第一个依赖
【发布时间】:2015-05-22 23:16:23
【问题描述】:

我有问题。我想有两个到数据库的连接。在第一个数据库中,我有登录信息和数据库名称,其他信息在哪里。使用 Node.js、mongoose 和 mongoDB 可以做到这一点吗?

【问题讨论】:

    标签: javascript angularjs node.js mongodb mongoose


    【解决方案1】:

    你可以这样做:

    var mongoose1       = require('mongoose'),
        mongoose2       = require('mongoose');
    
    mongoose1.connect('mongodb://FirstIPAdrress:27017/firstDatabase');
    
    //get values for the second database via find
    
    mongoose2.connect('mongodb://SecondIPAdrress:27017/secondDatabase');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-20
      • 1970-01-01
      • 2019-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-23
      • 2021-08-23
      相关资源
      最近更新 更多