Joel Reed wrote:
I've been poking around on the wiki site and googling for answers, but
can't quite come up with the right syntax yet to create a permanent
view and then GET the results.
I have a "test.view" file that looks like this:
{
"_id":"_design/forms",
"_rev":"12345",
"views":
{
"all": {
"map": "function(doc) { emit(doc.Patient, doc);
}" }
}
}
Then I say:
curl -v -H 'Content-Type: application/json;'
"http://localhost:5984/cs-cache/" --data-binary @/home/jreed/test.view
They I try to fire up:
http://localhost:5984/cs-cache/_view/_design/forms/all
Ok, I figured out what I was doing wrong. The correct steps appear to be:
1) Create a test.view file WITHOUT a "_rev" entry that looks like this:
{
"_id":"_design/forms",
"views":
{
"all": {
"map": "function(doc) { log(doc); emit(doc.Patient, doc); }"
}
}
}
2) Submit to couchdb with curl like this:
curl -v -X PUT -H 'Content-Type: application/json'
http://localhost:5984/cs-cache/_design/forms -T /home/jreed/test.view
3) test the view using a URL like this:
http://localhost:5984/cs-cache/_view/forms/all
Thanks Jan for helping me on the last step. I'm very new to couchdb,
thus my confusion.
jr