Creates new collection in database associated with this command.s
@param string $collectionName collection name
@param array $options collection options in format: "name" => "value"
@return bool whether operation was successful.
175140
public function createCollection($collectionName, array $options = [])
    {
        $this->document = $this->db->getQueryBuilder()->createCollection($collectionName, $options);

        $result = current($this->execute()->toArray());
        return $result['ok'] > 0;
    }
1026306
public function blockJson($blockName, $options = [])
    {
        if (array_key_exists('returnAll', $options) && $options['returnAll']) {
            // don't load blocks from db (otherwise every db block will always be found)
            return collect([])->toJson();
        }
        return parent::blockJson($blockName, $options);
    }
335002
public function getCollectionInfo(array $options = [])
    {
        $includeSystemCollections = false;
        // The includeSystemCollections option is no longer supported in the command
        if (isset($options['includeSystemCollections'])) {
            $includeSystemCollections = $options['includeSystemCollections'];
            unset($options['includeSystemCollections']);
        }

        try {
            $collections = $this->db->listCollections($options);
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e);
        }

        $getCollectionInfo = function (CollectionInfo $collectionInfo) {
            // @todo do away with __debugInfo once https://jira.mongodb.org/browse/PHPLIB-226 is fixed
            $info = $collectionInfo->__debugInfo();

            return array_filter(
                [
                    'name' => $collectionInfo->getName(),
                    'type' => isset($info['type']) ? $info['type'] : null,
                    'options' => $collectionInfo->getOptions(),
                    'info' => isset($info['info']) ? (array) $info['info'] : null,
                    'idIndex' => isset($info['idIndex']) ? (array) $info['idIndex'] : null,
                ],
                function ($item) {
                    return $item !== null;
                }
            );
        };

        $eligibleCollections = array_filter(
            iterator_to_array($collections),
            $this->getSystemCollectionFilterClosure($includeSystemCollections)
        );

        return array_map($getCollectionInfo, $eligibleCollections);
    }
1210259
public function setOptions(Collection $options)
    {
        /** @var OptionInterface $option */
        foreach ($options as $option) {
            $this->addOption($option);
        }

        return $this;
    }
1099285
public function createCollection($name, array $options = [])
    {
        return $this->bridge->createCollection($this->cName($name), $options);
    }
66048
public function insert($collectionName, array $data)
    {

        $collection = $this->db->selectCollection($this->dbName, $collectionName);
        $options    = [
            'w' => 1, // 设置写入需要ack确认
        ];
        return $collection->insert($data, $options);
    }
1001412
public function update ($collection_name, array $criteria, array $newObj, $options = array())
    {
        return $this->_call(
            'update', array(
                'collection_name' => $collection_name,
                'criteria'        => $criteria,
                'options'         => $options
            ), $newObj
        );
    }
365245
public function listIndexes($collectionName, array $options = [])
    {
        return $this->bridge->listIndexes($this->cName($collectionName), $options);
    }
5041
public function createBucket($bucketName, $options = [])
    {
        $this->beginProfile($token = "    > create bucket $bucketName ...");

        $this->db->createBucket($bucketName, $options);

        $this->endProfile($token);
    }
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));
    }
567612
public function delete($collectionName, $condition, $options = [])
    {
        $batchOptions = [];
        foreach (['bypassDocumentValidation'] as $name) {
            if (isset($options[$name])) {
                $batchOptions[$name] = $options[$name];
                unset($options[$name]);
            }
        }

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

        return $result['result'];
    }
1342106
public function delete($collectionName, $id)
    {

        $response = $this->doRequest('DELETE', 'collections/' . $collectionName . '/' . $id . '/');
        $body = $response->getBody()->getContents();
        return json_decode($body, true);
    }
1370093
protected function saveCollection(Collection $collection, array $options = []) {
		if ($collection->isInsertForced()) {
			unset($collection->_id);
			$collection->unforceInsert();
		}
		
		$result = true;
		
		foreach ($collection as $model) {
			if (! $this->saveModel($model, $options)) {
				$result = false;
			}
		}
		
		return $result;
	}
1226717
public function getCollection(string $collectionName): Collection
    {
        $collectionFile = $this->getCollectionFilePath($collectionName);
        $storage = $this->factory->storage($collectionFile, $this->type);
        return $this->factory->collection($storage);
    }
57004
public function insert($collectionName, $data)
    {
        $id = 0;
        $sql = $this->dialect->grammarInsert($collectionName, $data);

        $stid = oci_parse($this->raw, $sql);

        //Fixme : problem from other oracle dialect on method insert
        oci_bind_by_name($stid, ":id", $id,-1,SQLT_INT);

        foreach ($data as $key => $value) {
            oci_bind_by_name($stid, ":".$key, $data[$key]);
        }

        oci_execute($stid);

        oci_free_statement($stid);

        return $id;
    }
667330
public function createDocument($collection, array $data, array $options = [])
    {
        $this->setOptions($options);
        $doc = new Document($this->client, $this->database, $collection);
        $doc->setHeaders($this->getHeaders());
        $rs = $doc->create($data);
        $this->checkResponse($rs);
        unset($rs['_curl_info']);

        return $rs;
    }
461053
protected function collectionExists($collectionName): bool
    {
        foreach ($this->database->listCollections() as $collection) {
            if ($collection->getName() === $collectionName) {
                return true;
            }
        }

        return false;
    }