private function fetchCollection()
    {
        $contextOptions = $this->getContextOptions();

        if (isset($contextOptions[$this->_protocol]['collection'])) {
            $collection = $contextOptions[$this->_protocol]['collection'];
            if ($collection instanceof Collection) {
                throw new InvalidConfigException('"collection" context option should be an instance of "' . Collection::className() . '"');
            }

            return $collection;
        }

        $connection = isset($contextOptions[$this->_protocol]['db'])
            ? $contextOptions[$this->_protocol]['db']
            : 'mongodb';

        /* @var $connection Connection */
        $connection = Instance::ensure($connection, Connection::className());

        list($databaseName, $collectionPrefix) = explode('.', $this->_namespace, 2);
        return $connection->getDatabase($databaseName)->getFileCollection($collectionPrefix);
    }