node_modules/.cache/esm/37ab45f87abedcda.js
/**
 * Connect to MongoDB using a url as documented at
 *
 *  docs.mongodb.org/manual/reference/connection-string/
 *
 * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver
 *
 * @method
 * @param {MongoClient} mongoClient The MongoClient instance with which to connect.
 * @param {string} url The connection URI string
 * @param {object} [options] Optional settings. See MongoClient.prototype.connect for a list of options.
 * @param {MongoClient~connectCallback} [callback] The command result callback
 */
Connect to MongoDB using a url as documented at
docs.mongodb.org/manual/reference/connection-string

Note that for replicasets the replicaSet query parameter is required in the 2.0 driver

@method
@param {MongoClient} mongoClient The MongoClient instance with which to connect.
@param {string} url The connection URI string
@param {object} [options] Optional settings. See MongoClient.prototype.connect for a list of options.
@param {MongoClient~connectCallback} [callback] The command result callback
Connect to MongoDB using a url as documented at docs . mongodb . org / manual / reference / connection - string Note that for replicasets the replicaSet query parameter is required in the 2 . 0 driver @method @param { MongoClient } mongoClient The MongoClient instance with which to connect . @param { string } url The connection URI string @param { object } [ options ] Optional settings . See MongoClient . prototype . connect for a list of options . @param { MongoClient~connectCallback } [ callback ] The command result callback
function connect(mongoClient, url, options, callback) {
  options = Object.assign({}, options);
  if (callback == null) {
    throw new Error('no callback function provided');
  }
  const logger = Logger('MongoClient', options);
  if (url instanceof Server || url instanceof ReplSet || url instanceof Mongos) {
    return connectWithUrl(mongoClient, url, options, connectCallback);
  }
  const parseFn = options.useNewUrlParser ? parse : legacyParse;
  const transform = options.useNewUrlParser ? transformUrlOptions : legacyTransformUrlOptions;
  parseFn(url, options, (err, _object) => {
    if (err) return callback(err);
    const object = transform(_object);
    const _finalOptions = createUnifiedOptions(object, options);
    if (_finalOptions.socketTimeoutMS == null) _finalOptions.socketTimeoutMS = 360000;
    if (_finalOptions.connectTimeoutMS == null) _finalOptions.connectTimeoutMS = 30000;
    if (_finalOptions.db_options && _finalOptions.db_options.auth) {
      delete _finalOptions.db_options.auth;
    }
    mongoClient.s.options = _finalOptions;
    if (object.servers.length === 0) {
      return callback(new Error('connection string must contain at least one seed host'));
    }
    if (_finalOptions.replicaSet || _finalOptions.rs_name) {
      return createTopology(
        mongoClient,
        'replicaset',
        _finalOptions,
        connectHandler(mongoClient, _finalOptions, connectCallback)
      );
    } else if (object.servers.length > 1) {
      return createTopology(
        mongoClient,
        'mongos',
        _finalOptions,
        connectHandler(mongoClient, _finalOptions, connectCallback)
      );
    } else {
      return createServer(
        mongoClient,
        _finalOptions,
        connectHandler(mongoClient, _finalOptions, connectCallback)
      );
    }
  });
  function connectCallback(err, topology) {
    const warningMessage = `seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name`;
    if (err && err.message === 'no mongos proxies found in seed list') {
      if (logger.isWarn()) {
        logger.warn(warningMessage);
      }
      return callback(new MongoError(warningMessage));
    }
    callback(err, topology);
  }
}
function connect ( mongoClient , url , options , callback ) { options = Object . assign ( { } , options ) ; if ( callback == null ) { throw new Error ( 'no callback function provided' ) ; } const logger = Logger ( 'MongoClient' , options ) ; if ( url instanceof Server || url instanceof ReplSet || url instanceof Mongos ) { return connectWithUrl ( mongoClient , url , options , connectCallback ) ; } const parseFn = options . useNewUrlParser ? parse : legacyParse ; const transform = options . useNewUrlParser ? transformUrlOptions : legacyTransformUrlOptions ; parseFn ( url , options , ( err , _object ) => { if ( err ) return callback ( err ) ; const object = transform ( _object ) ; const _finalOptions = createUnifiedOptions ( object , options ) ; if ( _finalOptions . socketTimeoutMS == null ) _finalOptions . socketTimeoutMS = 360000 ; if ( _finalOptions . connectTimeoutMS == null ) _finalOptions . connectTimeoutMS = 30000 ; if ( _finalOptions . db_options && _finalOptions . db_options . auth ) { delete _finalOptions . db_options . auth ; } mongoClient . s . options = _finalOptions ; if ( object . servers . length === 0 ) { return callback ( new Error ( 'connection string must contain at least one seed host' ) ) ; } if ( _finalOptions . replicaSet || _finalOptions . rs_name ) { return createTopology ( mongoClient , 'replicaset' , _finalOptions , connectHandler ( mongoClient , _finalOptions , connectCallback ) ) ; } else if ( object . servers . length > 1 ) { return createTopology ( mongoClient , 'mongos' , _finalOptions , connectHandler ( mongoClient , _finalOptions , connectCallback ) ) ; } else { return createServer ( mongoClient , _finalOptions , connectHandler ( mongoClient , _finalOptions , connectCallback ) ) ; } } ) ; function connectCallback ( err , topology ) { const warningMessage = ` ` ; if ( err && err . message === 'no mongos proxies found in seed list' ) { if ( logger . isWarn ( ) ) { logger . warn ( warningMessage ) ; } return callback ( new MongoError ( warningMessage ) ) ; } callback ( err , topology ) ; } }
Connect to MongoDB using a url as documented at
  docs.mongodb.org/manual/reference/connection-string
Connect to MongoDB using a url as documented at docs . mongodb . org / manual / reference / connection - string
// If callback is null throw an exception // Get a logger for MongoClient // Did we pass in a Server/ReplSet/Mongos // Do not attempt to connect if parsing error // Flatten // Parse the string // Check if we have connection and socket timeout set // Store the merged options object // Failure modes // Do we have a replicaset then skip discovery and go straight to connectivity // Return a more specific error message for MongoClient.connect // Return the error and db instance