public function batchInsert(array &$a, array $options = [])
    {
        if (empty($a)) {
            throw new \MongoException('No write ops were included in the batch');
        }

        $continueOnError = isset($options['continueOnError']) && $options['continueOnError'];

        foreach ($a as $key => $item) {
            try {
                if (! $this->ensureDocumentHasMongoId($a[$key])) {
                    if ($continueOnError) {
                        unset($a[$key]);
                    } else {
                        trigger_error(sprintf('%s expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
                        return;
                    }
                }
            } catch (MongoException $e) {
                if (! $continueOnError) {
                    throw $e;
                }
            }
        }

        try {
            $result = $this->collection->insertMany(
                TypeConverter::fromLegacy(array_values($a)),
                $this->convertWriteConcernOptions($options)
            );
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e, 'MongoResultException');
        }

        if (! $result->isAcknowledged()) {
            return true;
        }

        return [
            'ok' => 1.0,
            'connectionId' => 0,
            'n' => 0,
            'syncMillis' => 0,
            'writtenTo' => null,
            'err' => null,
        ];
    }