public function batchInsert($collectionName, $documents, $options = [])
    {
        $this->document = [];
        foreach ($documents as $key => $document) {
            $this->document[$key] = [
                'type' => 'insert',
                'document' => $document
            ];
        }

        $result = $this->executeBatch($collectionName, $options);

        if ($result['result']->getInsertedCount() < 1) {
            return false;
        }

        return $result['insertedIds'];
    }
public function batchInsert($collectionName, $documents, $options = [])
    {
        $this->document = [];
        foreach ($documents as $key => $document) {
            $this->document[$key] = [
                'type' => 'insert',
                'document' => $document
            ];
        }

        $result = $this->executeBatch($collectionName, $options);

        if ($result['result']->getInsertedCount() < 1) {
            return false;
        }

        return $result['insertedIds'];
    }
public function batchInsert ( $ collectionName , $ documents , $ options = [ ] ) { $ this -> document = [ ] ; foreach ( $ documents as $ key => $ document ) { $ this -> document [ $ key ] = [ 'type' => 'insert' , 'document' => $ document ] ; } $ result = $ this -> executeBatch ( $ collectionName , $ options ) ; if ( $ result [ 'result' ] -> getInsertedCount ( ) < 1 ) { return false ; } return $ result [ 'insertedIds' ] ; }
Inserts batch of new documents into collection.
@param string $collectionName collection name
@param array[] $documents documents list
@param array $options list of options in format: optionName => optionValue.
@return array|false list of inserted IDs, `false` on failure.
Inserts batch of new documents into collection .