CouchDB
CouchDB copied to clipboard
Extend Result with more helpers
I added some more helpers to the Result
class, like this:
public function getFirstDoc()
{
$row = $this->getFirstRow();
return $row ? $row['doc'] : false;
}
public function getDocs()
{
return array_map(function($row) {
return $row['doc'];
}, $this->getRows());
}
public function isEmpty()
{
return !(bool)$this->data['rows'];
}
public function isError()
{
return array_key_exists('error', $this->data);
}
public function isNotFound()
{
return $this->isError() && ($this->data['error'] == 'not_found');
}
Maybe these could be usefull in your Result class.
The result class isn't really finished yet. Submit a PR, i will review and merge it :)