incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Catherine Jones <>
Subject list function "head" and "req" arguments
Date Wed, 01 Sep 2010 18:02:24 GMT

I'm looking for documentation re the "head" and "req" arguments supplied
to list functions (as mentined in the _Definitive Guide_.) It's not
clear to me how to extract information from them. My specific need is as

I have a couch database of documents with attached images. I have a
view with a map function that emits pairs of the form:

(doc_id, name_of_attached_image)

And I have a list function that assembles these images into a web page:

function(head, req) {
                  var s = '<!DOCTYPE html><html><body>'; 
                  while (row = getRow()) 
                      s += '<img src=\"' +\
                           row['value'][0] + '/' + \
                           row['value'][1] + '\" />'; 
                  s += '</body></html>';

Everything works fine locally, but if I want the same functionality
on my remote server (where 5984 is bound to rather than I need to replace in the list function with some
variable that evaluates to the name of the host being queried. I'm
guessing that the hostname can be extracted somehow from the head or
req arguments of the list function, but need a pointer to some info.



View raw message