/** * @test */ public function fetchMultipleDocumentsWorks() { $data = json_encode(array('name' => 'Foo')); $this->connector->put('/flow3_test/abc', array(), $data); $data = json_encode(array('name' => 'Bar')); $this->connector->put('/flow3_test/def', array(), $data); $data = json_encode(array('name' => 'Baz')); $this->connector->put('/flow3_test/ghi', array(), $data); $data = json_encode(array('keys' => array('abc', 'ghi'))); $response = $this->connector->post('/flow3_test/_all_docs', array('include_docs' => TRUE), $data); $this->assertObjectHasAttribute('rows', $response); $this->assertEquals(2, count($response->rows)); $row = $response->rows[1]; $this->assertEquals('Baz', $row->doc->name); $this->assertEquals(3, $response->total_rows); }
/** * Update a document * * @param mixed $document The document as a string, array or object * @param string $id The document id * @return \TYPO3\CouchDB\Client\StatusResponse The update response * @author Christopher Hlubek <*****@*****.**> * @author Karsten Dambekalns <*****@*****.**> */ public function updateDocument($document, $id) { $this->checkDocumentId($id); if (!is_string($document)) { $document = json_encode($document); } return $this->connector->put('/' . urlencode($this->getDatabaseName()) . '/' . $this->encodeId($id), NULL, $document); }