Returns the Mongo collection with the given name.
@param string $name collection name
@param bool $refresh whether to reload the collection instance even if it is found in the cache.
@return Collection Mongo collection instance.
180079
public function getCollection($name, $refresh = false)
    {
        if ($refresh || !array_key_exists($name, $this->_collections)) {
            $this->_collections[$name] = $this->selectCollection($name);
        }

        return $this->_collections[$name];
    }
742467
public function getHasManyByRelationName($name)
    {
        if ($table = $this->getReferencingTable($name)) {
            if ($model = static::getModelFromTable($table)) {
                $refField = $this->getReferencingField($table, $name);

                return $this->hasMany($model, $refField);
            }
        }

        return null;
    }
50196
public function getTable($name, $new = false)
    {
        $table = $this->db->getTable($name, $new);

        $table->setDatabase($this);

        return $table;
    }
1230140
final public function collection($name = '')
    {
        return new self($this->collection, $this->name.$name, $this, $this->prefixes);
    }
763022
public function findReversed($name, $reload = false, $type = 'all')
	{
		return $this->find($name, $reload, true, $type);
	}
1061628
public static function fetchByName( $name )
    {
        $result = parent::fetchObject( self::definition(), null, array( 'name' => $name ) );
        return $result;
    }
724158
protected function doSelectCollection($name)
    {
        $riakCollection = $this->riak->selectCollection($name);

        return new Collection($this, $riakCollection, $this->eventManager, $this->numRetries);
    }
344242
public function getChunkCollection($refresh = false)
    {
        if ($refresh || !is_object($this->_chunkCollection)) {
            $this->_chunkCollection = Yii::createObject([
                'class' => 'yii\mongodb\Collection',
                'database' => $this->database,
                'name' => $this->getPrefix() . '.chunks'
            ]);
        }

        return $this->_chunkCollection;
    }
739525
public function load($refresh = false)
    {
        $results = $this->repository->read();

        /* @var $config \Core\Config\ConfigObject */
        foreach ($results as $config) {
            $storage = $this->createStorage($config->getStorage());
            $storage->set($config->getId(), $config->getValue());
        }
    }
617021
public function get($name)
    {
        if (!array_key_exists($name, $this->items)) {
            throw new CollectionUnknownKeyException(sprintf('Item name=%s does not exist in collection',$name));
        }

        return $this->items[$name];
    }
726678
public function getRef($reference)
    {
        $array = ! isset($reference['$ref']);
        $reference = $array ? $reference : [$reference];
        $database = $this->database;

        $result = array_map(
            function ($ref) use ($database) {
                return MongoDBRef::get($database, $ref);
            },
            $reference
        );

        return $array ? $result : reset($result);
    }
1197524
public function getToken($refresh = false)
    {
        if ($this->token === null || $refresh)
        {
            $salt = $this->_createSalt(12);
            $name = session_name();

            $this->token = sha1($salt.$name);
        }

        return $this->token;
    }
902420
public function getTyped($name)
    {
        if(!array_key_exists($name, $this->typed_collections))
        {
            $collection = new FieldsCollection();

            foreach($this as $field)
            {
                if($field->getFieldType()->getName() === $name)
                {
                    $collection->addField($field);
                }
            }

            $this->typed_collections[$name] = $collection;
        }

        return $this->typed_collections[$name];
    }
457453
public static function instance($name = 'default')
	{
		if (\array_key_exists($name, static::$instances))
		{
			return static::$instances[$name];
		}

		if (empty(static::$instances))
		{
			\Config::load('db', true);
		}

		if ( ! ($config = \Config::get('db.mongo.'.$name)))
		{
			throw new \Mongo_DbException('Invalid instance name given.');
		}

		static::$instances[$name] = new static($config);

		return static::$instances[$name];
	}
1277195
public function getCatalogItem($name)
    {
        if (!($this->getFiller() instanceof FillerInterface)) {
            return;
        }

        try {
            $list = $this->search(['name' => $name]);
            if (count($list) == 1) {
                return $this->getFiller()->fillFromSearchResult(array_pop($list));
            }
        } catch (\Exception $e) {
        } // is not a critical error

        return;
    }
757099
public function selectCollection($name)
    {
        if (!isset($this->collection_cache[$name])) {
            $collection = new Collection($name, $this);
            $collection_cache[$name] = $collection;
        }

        return $collection_cache[$name];
    }
732950
public function findAllByLevelNameByLang(array $tree, bool $refresh = FALSE) : ObjectCollection
    {
        if (!$this->allPagesByLevelNameByLang || $refresh)
        {
            $this->allPagesByLevelNameByLang = $this->nestedSet->getFlatCollection($tree);
        }

        return $this->allPagesByLevelNameByLang;
    }