CouchDB Query View with Multiple Keys Formatting

function(doc){
    {
        if([doc.key1, doc.key2])
            emit([doc.key1, doc.thingYouWantToKnow]);
    }
}

and in the query string, at the end

?key=["key1Value", "key2Value"]

Notice that it is key=[], not keys=[] !!!!!!!!!


Not saying it's correct, but you can actually do it via query string as well. The array enclosing brackets should not be encoded. E.g. this works for me:

http://localhost:5984/test/_design/artists_albums/_view/albums_by_artist?keys=[%22Super%20bad%20artist%22,%20%22Fake%20artist%201%22]


To get multiple keys from a view, you need to do a post request and submit the keys in the request body. Your HTTP request will look like this:

POST /myDb/_design/myFilters/_view/getItemByForeignKeyId
Content-Type: application/json

{
   "keys" : [
      "abc",
      "123"
   ]
}

Tags:

Key

Couchdb

Views