lib/shared-mongo-connections.js
function getAdminDbUrl(mongoConnectionString, formUser, poolSize) {
  var parsedMongoUrl = mongoUrlParser.parse(mongoConnectionString);
  parsedMongoUrl.username = formUser.user;
  parsedMongoUrl.password = formUser.pass;
  //according to this: https://docs.mongodb.com/v2.4/reference/user-privileges/#any-database-roles, this type of user should be created in the `admin` database.
  parsedMongoUrl.database = "admin";
  parsedMongoUrl.options = parsedMongoUrl.options || {};
  parsedMongoUrl.options.poolSize = poolSize || MONGODB_DEFAULT_POOL_SIZE;
  var mongourl = mongoUrlParser.format(parsedMongoUrl);
  return mongourl;
}
function getAdminDbUrl(mongoConnectionString, formUser, poolSize) {
  var parsedMongoUrl = mongoUrlParser.parse(mongoConnectionString);
  parsedMongoUrl.username = formUser.user;
  parsedMongoUrl.password = formUser.pass;
  //according to this: https://docs.mongodb.com/v2.4/reference/user-privileges/#any-database-roles, this type of user should be created in the `admin` database.
  parsedMongoUrl.database = "admin";
  parsedMongoUrl.options = parsedMongoUrl.options || {};
  parsedMongoUrl.options.poolSize = poolSize || MONGODB_DEFAULT_POOL_SIZE;
  var mongourl = mongoUrlParser.format(parsedMongoUrl);
  return mongourl;
}
function getAdminDbUrl ( mongoConnectionString , formUser , poolSize ) { var parsedMongoUrl = mongoUrlParser . parse ( mongoConnectionString ) ; parsedMongoUrl . username = formUser . user ; parsedMongoUrl . password = formUser . pass ; //according to this: https://docs.mongodb.com/v2.4/reference/user-privileges/#any-database-roles, this type of user should be created in the `admin` database. parsedMongoUrl . database = "admin" ; parsedMongoUrl . options = parsedMongoUrl . options || { } ; parsedMongoUrl . options . poolSize = poolSize || MONGODB_DEFAULT_POOL_SIZE ; var mongourl = mongoUrlParser . format ( parsedMongoUrl ) ; return mongourl ; }
Get the url of the mongodb database that will the given formUser to connect.
@param {string} mongoConnectionString a mongodb url that should at least contain the mongodb hosts
@param {object} formUser a mongodb user that should have the "readWriteAnyDatabase" role to access any database. This type of user should exist in the mongo `admin` database.
@param {string} formUser.user the username
@param {string} formUser.pass the user password
@param {int} poolSize the poolSize of the mongodb connection. Default to 20.
@return {string} the mongodb connection url
Get the url of the mongodb database that will the given formUser to connect .