I used couchdb’s PHP lib to add a view:
public function addView() {
$design_doc = new stdClass();
$design_doc->_id = '_design/need';
$design_doc->language = 'javascript';
$design_doc->views = array( 'all' => array('map' => "function(doc) { if (doc.type == 'need') emit(doc.type, doc) }" ) );
$result = $this->client->storeDoc($design_doc);
return $result;
}
In my shell, I viewed its doc to confirm it was created:
curl -X GET mysite.com/bids/_design/need
{
"_id":"_design/need",
"_rev":"1-0ed4b41b839ade9ca36fb950cac1c39b",
"language":"javascript",
"views":
{
"all":
{
"map":"function(doc) { if (doc.type == 'need') emit(doc.type, doc) }"
}
}
}
Then when trying to actually execute the view, it throws eacces error:
curl -X GET mysite.com/bids/_design/need/_view/all
{
"error":"error","reason":"eacces"
}
Permissions: the instance is running as root.
Am I using the wrong syntax to execute the view query?
Could it be that there is an issue with the encoding of the string that was passed via PHP?
There was some issue with character encoding by php. Running the exact same query in curl was successful and the view was then able to run properly