CouchApp views show up will null results
I am new to CouchDB, but I am coming up empty trying to Google for this.
I have a view which has a result set of 2 documents when viewed from the DB host:5984/_utils/database.html?phistory/_design/phistory/_view/res
When I try to access this same view via a couch app, the results come back as a null document. host:5984/phistory/_design/phistory/_view/res
Result JSON when viewed from CouchApp:
{"rows":[
{"key":null,"value":null}
]}
Here is the map function from the view.
function(doc) {
开发者_JAVA百科 if(doc.query && doc.transactions){
emit(doc.query, doc.transactions);
}
}
Document
{
"_id": "fad95bf61bd2c87db4d017668a002191",
"_rev": "1-8bec74cf8022f91bdc9cb53fa8ff7599",
"query_group": "simple-select",
"query": "select id from FactV__c",
"transactions": {
"2011-06-01T12:13:15Z": "100",
"2011-07-01T12:13:15Z": "099"
}
}
According to this it looks like I am accessing the view correctly. http://wiki.apache.org/couchdb/HTTP_view_API
Adding debug output from the couch log for the request. You can see below that the actual view rendered the data from the DB perspective, but returned null to the response to the browser.
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.957.0>] 'GET' /phistory/_design/phistory/_view/res {1,1} Headers: [{'Accept',"text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"}, {'Accept-Charset',"ISO-8859-1,utf-8;q=0.7,*;q=0.3"}, {'Accept-Encoding',"gzip,deflate,sdch"}, {'Accept-Language',"en-US,en;q=0.8"}, {'Connection',"keep-alive"}, {'Cookie',"AuthSession=YnVpbGQ6NEUxREUzNTk6suAhrCjMRNN100LLDJqb0Dl-0Ag"}, {'Host',"cmarcel-ws:5984"}, {'If-None-Match',"\"5WLSLFYCQ880T9JCCPAMD804R\""}, {'User-Agent',"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30"}, {"X-Purpose",": preview"}]
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.957.0>] Successful cookie auth as: "build"
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.957.0>] request_group {Pid, Seq} {<0.907.0>,96}
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.957.0>] request_group {Pid, Seq} {<0.907.0>,96}
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.918.0>] OS Process #Port<0.2202> Input :: ["reset",{"reduce_limit":true}]
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.918.0>] OS Process #Port<0.2202> Output :: true
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.918.0>] OS Process #Port<0.2202> Input :: ["reduce",["function(keys, values, rereduce) {\n \n}"],[[["select id from FactV__c","fad95bf61bd2c87db4d017668a002191"],{"2011-06-01T12:13:15Z":"100","2011-07-01T12:13:15Z":"099"}]]]
[Wed, 13 Jul 2011 18:36:09 GMT] [debug] [<0.918.0>] OS Process #Port<0.2202> Output :: [true,[null]]
[Wed, 13 Jul 2011 18:36:09 GMT] [info] [<0.957.0>] 10.0.63.48 - - 'GET' /phistory/_design/phistory/_view/res 200
So I figured out what was going on. Apparently when you generate views through couchapp it creates and empty reduce function as well. It futon, you need to explicitly run the reduce so it didn't effect the results set. Through the app the empty reduce effectively nulled out the results. Thanks to all who responded.
精彩评论