Responds to the doctrine_mongodb configuration parameter.
519931
public function load(array $configs, ContainerBuilder $container)
    {
        // Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));

        $configuration = new Configuration();
        $config        = $this->processConfiguration($configuration, $configs);

        $loader->load('mongodb.xml');

        if (empty($config['default_connection'])) {
            $keys                         = array_keys($config['connections']);
            $config['default_connection'] = reset($keys);
        }
        $container->setParameter('doctrine_mongodb.odm.default_connection', $config['default_connection']);

        if (empty($config['default_document_manager'])) {
            $keys                               = array_keys($config['document_managers']);
            $config['default_document_manager'] = reset($keys);
        }
        $container->setParameter('doctrine_mongodb.odm.default_document_manager', $config['default_document_manager']);

        // set some options as parameters and unset them
        $config = $this->overrideParameters($config, $container);

        // set the fixtures loader
        $container->setParameter('doctrine_mongodb.odm.fixture_loader', $config['fixture_loader']);

        // load the connections
        $this->loadConnections($config['connections'], $container);

        $config['document_managers'] = $this->fixManagersAutoMappings($config['document_managers'], $container->getParameter('kernel.bundles'));

        // load the document managers
        $this->loadDocumentManagers(
            $config['document_managers'],
            $config['default_document_manager'],
            $config['default_database'],
            $container
        );

        if ($config['resolve_target_documents']) {
            $def = $container->findDefinition('doctrine_mongodb.odm.listeners.resolve_target_document');
            foreach ($config['resolve_target_documents'] as $name => $implementation) {
                $def->addMethodCall('addResolveTargetDocument', [$name, $implementation, []]);
            }
            $def->addTag('doctrine_mongodb.odm.event_listener', ['event' => 'loadClassMetadata']);
        }

        // BC Aliases for Document Manager
        $container->setAlias('doctrine.odm.mongodb.document_manager', new Alias('doctrine_mongodb.odm.document_manager'));

        $container->registerForAutoconfiguration(ServiceDocumentRepositoryInterface::class)
            ->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG);
    }
224250
function Fossa(options) {
  this.fuse();

  //
  // Store the options.
  //
  this.writable('queue', []);
  this.writable('plugins', {});
  this.writable('connecting', false);
  this.readable('options', configure(options || {}, this));

  //
  // Prepare a default model and collection sprinkled with MongoDB proxy methods.
  //
  this.readable('Model', model(this));
  this.readable('Collection', collection(this));

  //
  // Provide reference to the orginal mongo module so it can be used easily.
  //
  this.readable('mongo', mongo);

  //
  // Prepare connection.
  //
  this.init(
    this.options('hostname', 'localhost'),
    this.options('port', 27017),
    this.options
  );
}
558514
function configure(opts, done) {
  delete opts._;

  opts = defaults(opts, {
    topology: process.env.MONGODB_TOPOLOGY || 'standalone'
  });

  opts = defaults(opts, {
    name: opts.topology
  });

  opts = defaults(opts, {
    logpath: untildify(
      process.env.MONGODB_LOGPATH ||
        format('~/.mongodb/runner/%s.log', opts.name)
    ),
    pidpath: untildify(process.env.MONGODB_PIDPATH || '~/.mongodb/runner/pid'),
    port: process.env.MONGODB_PORT || 27017,
    mongodBin: process.env.MONGOD_BIN || 'mongod',
    mongosBin: process.env.MONGOS_BIN || 'mongos',
    storageEngine: process.env.MONGODB_STORAGE_ENGINE,
    auth_mechanism: process.env.MONGODB_AUTH_MECHANISM || 'none',
    purge: process.env.MONGODB_PURGE || true
  });

  // MongoDB < 3.0 doesn't understand the storageEngine argument and
  // will fail to start if provided!
  if (opts.version < '3.0') {
    delete opts.storageEngine;
  }

  if (opts.topology === 'replicaset') {
    opts = defaults(opts, {
      arbiters: process.env.MONGODB_ARBITERS || 0,
      secondaries: process.env.MONGODB_SECONDARIES || 2,
      passives: process.env.MONGODB_PASSIVES || 0
    });
  }

  if (opts.topology === 'cluster') {
    opts = defaults(opts, {
      shards: process.env.MONGODB_SHARDS || 1, // -> replsets
      routers: process.env.MONGODB_ROUTERS || 1, // -> mongoses
      configs: process.env.MONGODB_CONFIGS || 1,
      shardPort: process.env.MONGODB_SHARDS_PORT || 31000, // -> replsetStartPort
      configPort: process.env.MONGODB_CONFIGS_PORT || 35000, // -> configStartPort
      arbiters: process.env.MONGODB_ARBITERS || 0,
      secondaries: process.env.MONGODB_SECONDARIES || 2,
      passives: process.env.MONGODB_PASSIVES || 0
    });
  }

  debug('Ready to process spec', opts);

  if (opts.action === 'stop') {
    return done();
  }
  async.series(
    [
      mkdirp.bind(null, opts.pidpath),
      getDbPath.bind(null, opts),
      createLogsDirectory.bind(null, opts)
    ],
    done
  );
}
577984
private function setDoctrine(): void
    {
        $config        = Setup::createAnnotationMetadataConfiguration([], true, null, null, false);
        $entityManager = EntityManager::create([
            'driver'   => $this->config('DSN'),
            'user'     => $this->config('user'),
            'password' => $this->config('password'),
            'dbname'   => $this->config('name'),
        ], $config);

        $this->container()->set('db', $entityManager, 'raw');
    }
980932
protected function reEnableLogging()
    {
        //TODO: do we need to add support for MongoDB logging?
        if (!($this->objectManager instanceof \Doctrine\ORM\EntityManager)) return;

        $config = $this->objectManager->getConnection()->getConfiguration();
        $config->setSQLLogger($this->originalLogger);
    }
264458
function (db, entityName, doc, cb) {
			request.post({
				url: host + 'databases/' + db + '/docs',
				headers: {
					'Content-Type': 'application/json; charset=utf-8',
					'Raven-Entity-Name': entityName
				},
				body: JSON.stringify(doc)
			}, function (error, response, resBody) {
				if (!error && (response.statusCode === 201 || response.statusCode === 200)) {
					var result = JSON.parse(resBody);
					cb(null, result);
				} else {
					cb(error || new Error(response.statusCode), null);
				}
			});
		}
587676
private function getPhpType(string $doctrineType): ?string
    {
        switch ($doctrineType) {
            case MongoDbType::INTEGER:
            case MongoDbType::INT:
            case MongoDbType::INTID:
            case MongoDbType::KEY:
                return Type::BUILTIN_TYPE_INT;
            case MongoDbType::FLOAT:
                return Type::BUILTIN_TYPE_FLOAT;
            case MongoDbType::STRING:
            case MongoDbType::ID:
            case MongoDbType::OBJECTID:
            case MongoDbType::TIMESTAMP:
            case MongoDbType::BINDATA:
            case MongoDbType::BINDATABYTEARRAY:
            case MongoDbType::BINDATACUSTOM:
            case MongoDbType::BINDATAFUNC:
            case MongoDbType::BINDATAMD5:
            case MongoDbType::BINDATAUUID:
            case MongoDbType::BINDATAUUIDRFC4122:
                return Type::BUILTIN_TYPE_STRING;
            case MongoDbType::BOOLEAN:
            case MongoDbType::BOOL:
                return Type::BUILTIN_TYPE_BOOL;
        }

        return null;
    }
1025725
def get_database_configuration():
    """"""
    db_config = get_database_config_file()
    if db_config is None:
        return None
    with open(db_config, 'r') as ymlfile:
        cfg = yaml.load(ymlfile)
    return cfg
1092750
def simple_ensure_index(request, database_name, collection_name):
    """"""
    name = ""

    if request.method == 'POST':
        form = EnsureIndexForm(request.POST)

        if form.is_valid():
            result = form.save(database_name, collection_name)
            messages.success(request,
                             _("Index for %s created successfully" % result))
            return HttpResponseRedirect(reverse('djmongo_show_dbs'))
        else:
            # The form is invalid
            messages.error(
                request, _("Please correct the errors in the form."))
            return render(request,
                          'djmongo/console/generic/bootstrapform.html',
                          {'form': form, 'name': name})

    else:
        # this is a GET
        context = {'name': name,
                   'form': EnsureIndexForm(
                       initial={"database_name": database_name,
                                "collection_name": collection_name})
                   }
        return render(request, 'djmongo/console/generic/bootstrapform.html',
                      context)
999276
def get_repository_configuration(id):
    

    response = utils.checked_api_call(pnc_api.repositories, 'get_specific', id=id)
    if response:
        return response.content
1142300
public function prepare(string $confKey, string $db, string $collection)
    {
        $this->profileName = 'mongo.' . $db . '.';
        $this->config = getInstance()->config['mongodb'] ?? [];
        if (!isset($this->config[$confKey])) {
            throw new \MongoConnectionException('No such a MongoDB config ' . $confKey);
        }
        $conf = $this->config[$confKey];
        $this->mongoClient = new \MongoClient($conf['server'], $conf['options'], $conf['driverOptions']);
        $db && ($this->mongoDb = $this->mongoClient->selectDB($db));
        $collection && ($this->mongoCollection = $this->mongoDb->selectCollection($collection));
    }
469130
function initMongo(config, callback) {
  
  var self = this;
  
  // Set db
  self.db = new Db(config.database, new Server(config.host, config.port, {}), {safe: true});
  
  // Get client
  self.db.open(function(err, client) {
    if (err) throw err;
    else {
      self.client = client;
      client.collectionNames(function(err, names) {
        if (err) throw err;
        else {
          var name = config.database + '.' + config.collection;
          var exists = names.filter(function(col) {
            if (col.name == name) return col; 
          });
          
          // Collection options
          var opts = {capped: true, size: config.logSize};
          if (config.logLimit != null) opts.max = config.logLimit;
          
          if (exists.length === 0) {
            client.createCollection(config.collection, opts, function(err, collection) {
              if (err) throw err;
              else {
                self.collection = collection;
                callback.call(self);
              }
            });
          } else {
            // Get collection
            client.collection(config.collection, function(err, collection) {
              if (err) throw err;
              else {
                self.collection = collection;
                // Get collection options » Check if collection has already been capped
                collection.options(function(err, options) {
                  if (err) {
                    throw err;
                  } else {
                    // Check if collection's options match log requirements
                    var ready = (options.capped === true && options.size === opts.size);
                    if ('max' in opts) ready = (ready && options.max === opts.max);
                    if (!ready) {
                      // Convert collection to capped if it's not match log requirements
                      var cmd = {"convertToCapped": config.collection, size: opts.size};
                      if ('max' in opts) cmd.max = opts.max;
                      client.command(cmd, function(err) {
                        if (err) throw err;
                        else {
                          callback.call(self);
                        }
                      });
                    } else {
                      callback.call(self);
                    }
                  }
                });
              }
            });
          }
        }
      });
    }
  });
}
597098
def configure(self, proto):
        

        if not proto:
            defer.returnValue(None)

        reply = yield self.__send_ismaster(proto, timeout=self.initialDelay)

        # Handle the reply from the "ismaster" query. The reply contains
        # configuration information about the peer.

        # Make sure we got a result document.
        if len(reply.documents) != 1:
            raise OperationFailure("TxMongo: invalid document length.")

        # Get the configuration document from the reply.
        config = reply.documents[0].decode()

        # Make sure the command was successful.
        if not config.get("ok"):
            code = config.get("code")
            msg = "TxMongo: " + config.get("err", "Unknown error")
            raise OperationFailure(msg, code)

        # Check that the replicaSet matches.
        set_name = config.get("setName")
        expected_set_name = self.uri["options"].get("replicaset")
        if expected_set_name and (expected_set_name != set_name):
            # Log the invalid replica set failure.
            msg = "TxMongo: Mongo instance does not match requested replicaSet."
            raise ConfigurationError(msg)

        # Track max bson object size limit.
        proto.max_bson_size = config.get("maxBsonObjectSize", DEFAULT_MAX_BSON_SIZE)
        proto.max_write_batch_size = config.get("maxWriteBatchSize", DEFAULT_MAX_WRITE_BATCH_SIZE)

        proto.set_wire_versions(config.get("minWireVersion", 0),
                                config.get("maxWireVersion", 0))

        # Track the other hosts in the replica set.
        hosts = config.get("hosts")
        if isinstance(hosts, list) and hosts:
            for host in hosts:
                if ':' not in host:
                    host = (host, 27017)
                else:
                    host = host.split(':', 1)
                    host[1] = int(host[1])
                    host = tuple(host)
                if host not in self.__allnodes:
                    self.__allnodes.append(host)

        # Check if this node is the master.
        ismaster = config.get("ismaster")
        if not ismaster:
            msg = "TxMongo: MongoDB host `%s` is not master." % config.get('me')
            raise AutoReconnect(msg)
278151
protected function __init_database($param = null)
    {

        if ($this->_default_database_type == '') {
            $this->_default_database_type = Config::get('default_database_type');
        }

        if (isset($param['type']) && is_string($param['type'])) {
            $this->database_type = $param['type'];
        } else {
            $this->database_type = $this->_default_database_type;
        }


        switch (true) {
            case ($this->db instanceof Mysql):
                return true;
            case ($this->db instanceof CouchDB):
                return true;
            case ($this->db instanceof Mongo):
                return true;
        }


        try {
            switch ($this->database_type) {
                case 'mysql':
                    $master_param = new MysqlConnection([
                        'host'     => (string)Config::get('db_host'),
                        'username' => (string)Config::get('db_user'),
                        'password' => (string)Config::get('db_pass'),
                        'database' => (string)Config::get('db_name'),
                        'port'     => (string)Config::get('db_port')
                    ]);

                    $this->db = new Mysql($master_param);
                    break;
                case 'couchdb':
                    $this->db = new CouchDB();
                    break;
                case 'mongo':
                    break;
            }

        } catch (DatabaseException $e) {
            throw $e;
        }

        return true;
    }
586370
private static function prepareIndexConfig()
    {
        foreach (self::$storage as $className => $id) {
            $key = IndexHelper::storageClassToType($className);
            $config = self::prepareMapping($className);
            if (false === empty($config)) {
                self::$indexConfig['body']['mappings'][$key] = $config;
            }
        }
        return self::$indexConfig;
    }
1137240
function (db, id, wantedPropsFromMetadata, cb) {
			if(Object.prototype.toString.call(wantedPropsFromMetadata) == '[object Function]'){
				cb = wantedPropsFromMetadata;
				wantedPropsFromMetadata = [];
			}
			var url = host + 'databases/' + db + '/docs/' + id;
			request(url, function (error, response, body) {
				if(error || response.statusCode != 200)
					return cb(error || new Error(response.statusCode));
				var doc = JSON.parse(body);
				var meta = _.reduce(response.headers
					, function (memo, val, key) {
						if (key.indexOf('raven') === 0 || wantedPropsFromMetadata.indexOf(key) != -1)
							memo[key] = val;
						return memo;
					}, {});
				meta['@id'] = response.headers['__document_id'];
				meta.etag = response.headers['etag'];
				meta.dateCreated = response.headers['DateCreated'] || response.headers['datecreated'];
				doc['@metadata'] = meta;
				cb(null, doc);
			});
		}
323566
public function ok(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
    {
        return $this->getResourceResponse($document, $object, 200, $additionalMeta);
    }