public function import(
        $collection,
        $importData,
        array $options = []
    )
    {
        $collection = $this->makeCollection($collection);

        $tmpContent = '';
        if (is_array($importData)) {
            foreach ($importData as $document) {
                /** @var $document Document */
                $tmpContent .= $document->toJson() . "\r\n";
            }
            $importData = $tmpContent;
            unset($tmpContent);
            $options['type'] = 'documents';
        }

        $this->createCollectionIfOptions($collection, $options);

        $params = array_merge(
            [self::OPTION_COLLECTION => $collection],
            $options
        );

        if (array_key_exists('type', $options)) {
            switch ($options['type']) {
                case 'documents':
                    $params[self::OPTION_TYPE] = 'documents';
                    break;
                case 'array':
                    $params[self::OPTION_TYPE] = 'array';
                    break;
            }
        }

        $url = UrlHelper::appendParamsUrl(Urls::URL_IMPORT, $params);

        $response = $this->getConnection()->post($url, $importData);

        return $response->getJson();
    }
public function import(
        $collection,
        $importData,
        array $options = []
    )
    {
        $collection = $this->makeCollection($collection);

        $tmpContent = '';
        if (is_array($importData)) {
            foreach ($importData as $document) {
                /** @var $document Document */
                $tmpContent .= $document->toJson() . "\r\n";
            }
            $importData = $tmpContent;
            unset($tmpContent);
            $options['type'] = 'documents';
        }

        $this->createCollectionIfOptions($collection, $options);

        $params = array_merge(
            [self::OPTION_COLLECTION => $collection],
            $options
        );

        if (array_key_exists('type', $options)) {
            switch ($options['type']) {
                case 'documents':
                    $params[self::OPTION_TYPE] = 'documents';
                    break;
                case 'array':
                    $params[self::OPTION_TYPE] = 'array';
                    break;
            }
        }

        $url = UrlHelper::appendParamsUrl(Urls::URL_IMPORT, $params);

        $response = $this->getConnection()->post($url, $importData);

        return $response->getJson();
    }
public function import ( $ collection , $ importData , array $ options = [ ] ) { $ collection = $ this -> makeCollection ( $ collection ) ; $ tmpContent = '' ; if ( is_array ( $ importData ) ) { foreach ( $ importData as $ document ) { /** @var $document Document */ $ tmpContent .= $ document -> toJson ( ) . "\r\n" ; } $ importData = $ tmpContent ; unset ( $ tmpContent ) ; $ options [ 'type' ] = 'documents' ; } $ this -> createCollectionIfOptions ( $ collection , $ options ) ; $ params = array_merge ( [ self :: OPTION_COLLECTION => $ collection ] , $ options ) ; if ( array_key_exists ( 'type' , $ options ) ) { switch ( $ options [ 'type' ] ) { case 'documents' : $ params [ self :: OPTION_TYPE ] = 'documents' ; break ; case 'array' : $ params [ self :: OPTION_TYPE ] = 'array' ; break ; } } $ url = UrlHelper :: appendParamsUrl ( Urls :: URL_IMPORT , $ params ) ; $ response = $ this -> getConnection ( ) -> post ( $ url , $ importData ) ; return $ response -> getJson ( ) ; }
Import documents into a collection

This will throw on all errors except insertion errors


@param              $collection   mixed $collection - collection id as string or number
@param string|array $importData   - The data to import. This can be a string holding the data according to the type of import, or an array of documents
@param array        $options      - optional - an array of options.
<p>Options are :<br>
<li>
'type' -  if type is not set or it's set to '' or null, the Header-Value format must be provided in the import file.<br>
<p>
<li>                       if set to 'documents', then the file's content must have its documents line by line. Each line will be interpreted as a document.</li>
<li>                       if set to 'array' then the file's content must provide the documents as a list of documents instead of the above line by line.</li>
<br>
More info on how the import functionality works: <a href ="https://github.com/triAGENS/ArangoDB/wiki/HttpImport">https://github.com/triAGENS/ArangoDB/wiki/HttpImport</a>
</p>
<br>

</li>
<li>'createCollection' - If true, create the collection if it does not exist. Defaults to false </li>
</p>

Other options as described in API Documentation*

@see https://docs.arangodb.com/3.1/HTTP/BulkImports/

@return array
@throws \ArangoDBClient\Exception
@throws \ArangoDBClient\ClientException
Import documents into a collection