Mongoose.prototype.connections

Type:
  • «Array»

An array containing all connections associated with this Mongoose instance. By default, there is 1 connection. Calling createConnection() adds a connection to this array.

Example:

  1. const mongoose = require('mongoose');
  2. mongoose.connections.length; // 1, just the default connection
  3. mongoose.connections[0] === mongoose.connection; // true
  4. mongoose.createConnection('mongodb://localhost:27017/test');
  5. mongoose.connections.length; // 2