public function createCollection($collectionName, array $options = [])
    {
        if ( ! isset($options['typeMap'])) {
            $options['typeMap'] = $this->typeMap;
        }

        $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));

        if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForWritableCommandWriteConcern)) {
            $options['writeConcern'] = $this->writeConcern;
        }

        $operation = new CreateCollection($this->databaseName, $collectionName, $options);

        return $operation->execute($server);
    }
public function createCollection($collectionName, array $options = [])
    {
        if ( ! isset($options['typeMap'])) {
            $options['typeMap'] = $this->typeMap;
        }

        $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));

        if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForWritableCommandWriteConcern)) {
            $options['writeConcern'] = $this->writeConcern;
        }

        $operation = new CreateCollection($this->databaseName, $collectionName, $options);

        return $operation->execute($server);
    }
public function createCollection ( $ collectionName , array $ options = [ ] ) { if ( ! isset ( $ options [ 'typeMap' ] ) ) { $ options [ 'typeMap' ] = $ this -> typeMap ; } $ server = $ this -> manager -> selectServer ( new ReadPreference ( ReadPreference :: RP_PRIMARY ) ) ; if ( ! isset ( $ options [ 'writeConcern' ] ) && \ MongoDB \ server_supports_feature ( $ server , self :: $ wireVersionForWritableCommandWriteConcern ) ) { $ options [ 'writeConcern' ] = $ this -> writeConcern ; } $ operation = new CreateCollection ( $ this -> databaseName , $ collectionName , $ options ) ; return $ operation -> execute ( $ server ) ; }
Create a new collection explicitly.

@see CreateCollection::__construct() for supported options
@param string $collectionName
@param array  $options
@return array|object Command result document
@throws UnsupportedException if options are not supported by the selected server
@throws InvalidArgumentException for parameter/option parsing errors
@throws DriverRuntimeException for other driver errors (e.g. connection errors)
Create a new collection explicitly .