Reputation: 3891
I create a simple couchapp and deployed it into my CouchDB instance. However, i'm noticing an anomaly. The view created (via couchapp generate view ...) returns data when I view it in CouchDB's Futon administrative interface (logged in as admin), but not when I run the couchapp I wrote. Here's an example of my code:
$.CouchApp(function(app) {
app.view("wine_list", { success: function(json) {
json.rows.map(function(row) {
alert(row.key);
});
}});
});
The result I get out of alert() above is 'null'.
And when I navigate to: http://localhost:5984/winedb/_design/wineapp/_view/wine_list I get:
{"rows":[
{"key":null,"value":null}
]}
But, If I open Futon admin interface and navigate to the design doc/view, I can see records. Now, in Futon i'm logged in as admin. So, my guess is I should specific auth credentials in my couchapp javascript code? If so, how?
Upvotes: 3
Views: 394
Reputation: 73752
If your view has both a map and reduce component, then this might be a user interface bug in Futon.
By default, CouchDB will supply map and reduce results to queries. To see only the map results, you must provide a ?reduce=false
parameter.
By default, Futon provides the ?reduce=false
parameter, and you have to check the "reduce" checkbox to get the "default" behavior.
In other words, add reduce=false
to your query. Does that help?
Upvotes: 5