title: Mongoose models from two connections
body: <p>I have the following setup:</p>
  
  <p><strong>/models/index.js</strong></p>
  
  <pre><code>var glob = require('glob');
  var mongoose = require('mongoose');
  var Promise = require('bluebird');
  mongoose.Promise = Promise;
  
  mongoose.connect('mongodb://localhost/firstDB', {
    useMongoClient: true
  });
  
  var models = glob.sync(__dirname + '/*.js', {ignore: '**/index.js'});
  models.forEach(function (model) {
    require(model);
  });
  </code></pre>
  
  <p><strong>/models/movie.js</strong></p>
  
  <pre><code>var mongoose = require('mongoose');
  var movieSchema = new mongoose.Schema({
    title: String
  }, {timestamps: true});
  
  mongoose.model('movie', movieSchema);
  </code></pre>
  
  <p><strong>/app.js</strong></p>
  
  <pre><code>require('./models');
  ...
  var Movie = mongoose.model('movie');
  ...
  </code></pre>
  
  <p>I would like to access <code>secondDB</code> models from the same <code>app.js</code> file, how can I do that?</p>
  
  <hr>
  
  <p><strong>Update:</strong> The end setup should look something like that:<br>
  (not sure how to pass the connection to the model)</p>
  
  <p><strong>/models/index.js</strong></p>
  
  <pre><code>var glob = require('glob');
  var mongoose = require('mongoose');
  var Promise = require('bluebird');
  mongoose.Promise = Promise;
  
  var firstConnection = mongoose.connect('mongodb://localhost/firstDB', {
    useMongoClient: true
  });
  var secondConnection = mongoose.connect('mongodb://localhost/secondDB', {
    useMongoClient: true
  });
  
  var firstModels = glob.sync(__dirname + '/*.js', {ignore: '**/index.js'});
  firstModels.forEach(function (model) {
    require(model);
  });
  var secondModels = glob.sync(__dirname + '/second/*.js');
  secondModels.forEach(function (model) {
    require(model);
  });
  </code></pre>
  
  <p><strong>/models/movie.js</strong></p>
  
  <pre><code>var mongoose = require('mongoose');
  var movieSchema = new mongoose.Schema({
    title: String
  }, {timestamps: true});
  
  mongoose.model('movie', movieSchema);
  </code></pre>
  
  <p><strong>/models/second/car.js</strong></p>
  
  <pre><code>var mongoose = require('mongoose');
  var carSchema = new mongoose.Schema({
    color: String
  }, {timestamps: true});
  
  mongoose.model('car', carSchema);
  </code></pre>
  
  <p><strong>/app.js</strong></p>
  
  <pre><code>require('./models');
  ...
  var Movie = mongoose.model('movie');
  var Car = mongoose.model('car');
  ...
  </code></pre>