1
votes

I'm following IBM's tutorial on CouchDB and ran into a problem viewing my docs. When I visit http://127.0.0.1:5984/_utils/database.html?contacts/_design/contacts/_view/byname#, I can see my docs in the view just fine.

enter image description here

However, when I visit http://127.0.0.1:5984/contacts/_design/contacts/_view/byname (and subsequently try to view the same data in my app via db.view("contacts/byname", {...), I only see null results for my key/value pairs.

enter image description here

I don't think it's a security issue; I'm able to see the view in _utils whether I'm logged in or not.

EDIT

Here is the source code for my view:

function(doc) {
   if (doc.name) {
      emit(doc.name, doc);
   }
}

Why can I see it in one place but not the other?

2
What does your view source code look like?Dominic Barnes
I've updated the question with my source code.Matt Norris

2 Answers

2
votes

As suggested by Antonios, the command

couchapp generate view contacts byname

has created a file views/byname/reduce.js with an empty reduce function. You should remove it or query with ?reduce=false (Futon adds it by default.)

As a side note: while using Futon, you can use Firebug to see the queries that are being done.

2
votes

Perhaps you have a reduce function that discards the document contents, or reduces to null? I see from your screenshot that you haven't clicked the "Reduce" checkbox, thus what you see is results just from the map function.