Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create View doc is incorrect #10

Closed
couchdbuser2 opened this issue Oct 3, 2010 · 4 comments
Closed

Create View doc is incorrect #10

couchdbuser2 opened this issue Oct 3, 2010 · 4 comments

Comments

@couchdbuser2
Copy link

Hi,

I read http://github.com/dready92/PHP-on-Couch/blob/master/doc/couch_client-view.md to create a view but the section:

$view_fn="function(doc) { emit(doc.timestamp,null); }";
$design_doc->_id = '_design/all';
$design_doc->language = 'javascript';
$design_doc->views = array ( 'by_date',$view_fn);
$client->storeDoc($design_doc);

should be:

$view_fn="function(doc) { emit(doc.timestamp,null); }";
$design_doc->_id = '_design/all';
$design_doc->language = 'javascript';
$design_doc->views = array ( 'by_date' => 'map' => $view_fn);
$client->storeDoc($design_doc);

otherwise it will not really create a view

@dready92
Copy link
Owner

dready92 commented Oct 4, 2010

Hello,

You're perfectly right. Thank you to report this error to me. Commit e60a901 fixed the bug.

Regards,

Mickael

@couchdbuser2
Copy link
Author

Thank you for such an easy to use wrapper!

Regards,

@SMut
Copy link

SMut commented Dec 25, 2010

thanks couchdbuser2 for the patch. as I am a newbie to couchDB I got stuck.: a database without getting results is useless. you made my day! merry Xmas by the way!

@SMut
Copy link

SMut commented Dec 25, 2010

Phew, this issue really popped me out of my socks. couchdbuser2 had some nice bugs in it:
$design_doc->id = 'design/all';
id needs an underscore: _id

$design_doc->views = array ( 'by_date' => 'map' => $view_fn); $client->storeDoc($design_doc);

This one won't work (at least with my php version), you have to define map as an array.

here is my version (tested on a couchdb -v 0.10.0 lighttpd 1.4.26 PHP 5.3.2)
$design_doc->_id = 'design/all';
$design_doc->language = 'javascript';
$view_fn=array( 'map' => 'function(doc) { emit(doc.timestamp,null); }');
$design_doc->views = array ( 'by_date' => $view_fn );
$client->storeDoc($design_doc);
This one works and shows this sourceview in futon:
{
"_id": "design/all",
"_rev": "1-fa2ce68ff2bc648c92ff0502f44e8adb",
"language": "javascript",
"views": {
"by_date": {
"map": "function(doc) { emit(doc.timestamp,null); }"
}
}
}
This is fine.
(PHP hates me, but it's okay ;-)

ClemensSahs added a commit to ClemensSahs/PHP-on-Couch that referenced this issue Dec 13, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants