Struggling to get any list function to work. I’ve been fine with _show and _view functions, but lists don’t seem to be working, or I have misunderstood what to do! (I’ll admit to needing an idiot’s guide!)
My design document looks like:
{
"_id": "_design/lists",
"_rev": "3-d22225b4a28a6ca11484723c3a37201b",
"language": "javascript",
"views": {
"variants": {
"map": "function(doc) { emit(doc.var, doc.number_of_results); }"
}
},
"lists": {
"results": "function(head, req) { var row; while(row = getRow()) {send(row.value);}}"
}
}
When I enter http://localhost:5984/mydb/_design/lists/_view/variants I get a list of variant names, like:
...{"id":"f050ad9b9f725443cb8c4071f40583b","key":"rs1013940","value":19008},
{"id":"f050ad9b9f725443cb8c4071f40daff","key":"rs1013940","value":19008},
{"id":"f050ad9b9f725443cb8c4071f40b985","key":"rs1021188","value":10197}...
but when I enter http://localhost:5984/mydb/_design/lists/_list/results I get:
{"error":"list_error","reason":"Invalid path."}
Does anyone know what I’m doing wrong? I’ve tried everything I can think of and swapping the function for one from any of the online tutorials.
I’m using CouchDB version 1.0.1 on Ubuntu 12.04
Many thanks, hope someone can help!
You need to include both a view name as well as a list name in your URL:
http://localhost:5984/:db/_design/:ddoc/_list/:list/:viewwhich in your case translates to:
http://localhost:5984/mydb/_design/lists/_list/results/variants