public function createDesignDocument()
    {
        if (!$this->doc) {
            throw new \Exception('No DesignDocument Class is connected to this view query, cannot create the design document with its corresponding view automatically!');
        }

        $data = $this->doc->getData();
        if ($data === null) {
            throw \Doctrine\CouchDB\JsonDecodeException::fromLastJsonError();
        }
        $data['_id'] = '_design/'.$this->designDocumentName;

        $response = $this->client->request(
            'PUT',
            sprintf(
                '/%s/_design/%s',
                $this->databaseName,
                $this->designDocumentName
            ),
            json_encode($data)
        );
    }