@param string $collectionName
@param array  $options

@return Collection
761813
public function getCollection($collectionName, array $options = []): Collection
    {
        $cacheKey = $collectionName.$this->getCollectionOptionsHash($options);
        if (!array_key_exists($cacheKey, $this->collectionsCache)) {
            $this->collectionsCache[$cacheKey] = $this->database->selectCollection(
                $collectionName,
                $options
            );
        }

        return $this->collectionsCache[$cacheKey];
    }
1206103
public Map<String, Map<String,Object>> getCollection(String collectionName) {
        // return specified collection Map which is indexed by document ID
        return mCollections.get(collectionName);
    }
11733
public function aggregate($collectionName, $pipelines, $options = [])
    {
        foreach ($pipelines as $key => $pipeline) {
            if (isset($pipeline['$match'])) {
                $pipelines[$key]['$match'] = $this->buildCondition($pipeline['$match']);
            }
        }

        $document = array_merge(
            [
                'aggregate' => $collectionName,
                'pipeline' => $pipelines,
                'allowDiskUse' => false,
            ],
            $options
        );

        return $document;
    }
1240690
public function listCollections(array $options = [])
    {
        $collections = [];
        foreach ($this->collections as $name => $collection) {
            $collections[] = [
                'name' => $this->name . '.' . $name,
                'options' => $collection['options']
            ];
        }

        return new CollectionInfoLegacyIterator(new ArrayIterator($collections));
    }
212353
public function update($collectionName, $condition, $document, $options = [])
    {
        $batchOptions = [];
        foreach (['bypassDocumentValidation'] as $name) {
            if (isset($options[$name])) {
                $batchOptions[$name] = $options[$name];
                unset($options[$name]);
            }
        }

        $this->document = [];
        $this->addUpdate($condition, $document, $options);
        $result = $this->executeBatch($collectionName, $batchOptions);

        return $result['result'];
    }
567773
public function collection($name, array $options = []): FieldTypeInterface
    {
        return (new CollectionType($name))
            ->setLocale($this->app->getLocale())
            ->setViewFactory($this->viewFactory)
            ->setOptions($options);
    }
545708
public function dropIndex($collection, $indexName, array $options = [])
    {
        $col = $this->db->selectCollection($collection);

        return $col->dropIndex($indexName, $options);
    }
59431
function collector($options = null)
    {
        if (! $this->collector )
            $this->collector = new DataCollector;

        if (null !== $options) {
            $this->collector->import($options);
            return $this;
        }

        return $this->collector;
    }
90619
public function createCollection($name, array $options = null)
    {
        $classDefinition = $this->getCollectionDefinition($name);
        
        if (!empty($options)) {
            $classDefinition->merge($options);
        }

        $mongoCollection = $this->getMongoDB()->createCollection(
            $name,
            $classDefinition->getMongoCollectionOptions()
        );

        // create collection
        $className = $classDefinition->getClass();
        return new $className(
            $this,
            $mongoCollection,
            $classDefinition
        );
    }
27486
public function count($collectionName, $condition = [], $options = [])
    {
        $this->document = $this->db->getQueryBuilder()->count($collectionName, $condition, $options);

        $result = current($this->execute()->toArray());
        return $result['n'];
    }
1293448
public function getCollection($collectionName)
    {
        $this->initialize();

        return isset($this->collections[$collectionName]) ? $this->collections[$collectionName] : null;
    }
559415
public function findByCollectionNameIterator($collectionName)
    {
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        return $queryBuilder
            ->select('PersistentResource')
            ->from($this->getEntityClassName(), 'PersistentResource')
            ->where('PersistentResource.collectionName = :collectionName')
            ->setParameter(':collectionName', $collectionName)
            ->getQuery()->iterate();
    }
573284
static function transform($modelOrCollection, $options = [])
    {
        $static = new static($options);

        if ($modelOrCollection instanceof Collection) {
            return $modelOrCollection->map([$static, 'transformModel'])->toArray();
        }

        return $static->transformModel($modelOrCollection);
    }
359664
public function collectionItem(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateCollectionItem();
        $this->validateBool('status');
        $this->validateWeight();
        $this->validateUrlCollectionItem();
        $this->validateCollectionCollectionItem();
        $this->validateEntityIdCollectionItem();
        $this->validateEntityCollectionItem();
        $this->validateData();

        $this->unsetSubmitted('update');
        $this->unsetSubmitted('collection');

        return $this->getResult();
    }
187853
public function remove($collectionName, array $criteria = [], array $options = []) {
		$collection = $this->getCollection($collectionName);
		
		if ($this->_profilerEnabled) {
			$message = 'db.remove(' . json_encode($criteria) . ');';
			$event   = $this->getProfiler()->startDelete($message);
		}

		$result  = $collection->remove($criteria, $options);
		$success = (bool) $result['ok'];
		
		if ($this->_profilerEnabled) {
			$success
				? $event->stopSuccess()
				: $event->stopError();
		}
		
		return $success;
	}
928935
public function createCollection($name, array $options = [])
    {
        if (isset($this->collections[$name])) {
            throw new RuntimeException('collection already exists');
        }

        $this->collections[$name] = [
            'collection' => new MockCollection($name, $this),
            'options' => $options
        ];

        return [
            'ok' => 1.0
        ];
    }
996848
public function options($options = [])
    {
        if (!$this->keyAsValue) {
            return parent::options($options);
        }

        if ($options instanceof Collection) {
            $options = $options->pluck($this->visibleColumn, $this->key)->toArray();
        }

        if ($options instanceof Arrayable) {
            $options = $options->toArray();
        }

        $this->options = $options + $this->options;

        return $this;
    }