To query a couch db database you can sent a http GET request in the style of
host:5984/db/_design/some_view/_view/view1?key="foo"
To make a simple view named view1 to it I could create the map
function(doc){
emit(doc.bar,doc);
}
That will produce a list of key-value pairs where doc.bar is the key and doc is the value. In this case it is a subset of the db where doc.bar = "foo"
It seems the emit function compares its parameter agains the key parameter passed with the URL request.
How could i get the value of key from the URL and do checks on it before it is passed to emit?