docs: function connect(dbUri, debugFlag, mongos) {
      var deferred = Q.defer();
      var opts = {
          server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
          replset: { socketOptions: { keepAlive: 1, connectTimeoutMS : 30000 } }
      };
  
      if (mongos) {
          opts.mongos = true;
      }
  
      mongoose.set('debug', debugFlag);
  
      // make sure we disconnect any other existing connections
      mongoose.disconnect(function () {
          mongoose.connect(dbUri, opts, function (err)  {
              err ? deferred.reject(err) : deferred.resolve();
          });
      });
  
      return deferred.promise;
  }