public function batchInsert($rows, $validate = true)
    {
        if ($validate) {
            $document = $this->createDocument();
            foreach ($rows as $row) {
                $document->merge($row);

                if (!$document->isValid()) {
                    throw new InvalidDocumentException('Document is invalid on batch insert');
                }

                $document->reset();
            }
        }

        $result = $this->getMongoCollection()->batchInsert($rows);

        // If the w parameter is set to acknowledge the write,
        // returns an associative array with the status of the inserts ("ok")
        // and any error that may have occurred ("err").
        if (is_array($result)) {
            if ($result['ok'] != 1) {
                throw new Exception('Batch insert error: ' . $result['err']);
            }

            return $this;
        }

        // Otherwise, returns TRUE if the batch insert was successfully sent,
        // FALSE otherwise.
        if (!$result) {
            throw new Exception('Batch insert error');
        }

        return $this;
    }