0

I have some documents in CouchDB of type: "Person" and of type "Account".

For a straight list of all documents of these types I have created the following design document in _design/directory_views:

{
   "_id": "_design/directory_views",
   "_rev": "21-f5df9253504e66f28393f4bda360e110",
   "views": {
       "all_persons": {
           "map": "(function(doc) { if (doc.type == \"Person\") { emit(null, { 'last_name': doc.last_name, 'first_name': doc.first_name }); } })"
       },
       "all_accounts": {
           "map": "(function(doc) { if (doc.type == \"Account\") { emit(null, { 'username': doc.username }); } })"
       }
   }
}

This JSON validates on JSONLint and is accepted when saving the document in Futon's source view.

Futon lists directory_views/all_persons and directory_views/all_accounts as expected in the dropdown. all_persons creates the correct list of documents of type "Person", however all_accounts redirects back to the toplevel All Documents, and lists everything.

Why does all_persons work, but all_accounts fail?

PS. I've experienced this behavior on a number of design documents so far. This example http://kore-nordmann.de/blog/couchdb_a_use_case.html#a-practical-example shows two views in the same design document, so I don't think that you can only have one view per document.

Hellfire
  • 25
  • 4
  • 2
    I'm not having any problems, what version of CouchDB are you using? What do your documents look like? Have you tried outside of futon just in case? – Dominic Barnes May 17 '12 at 14:25
  • Hmmm... Seems to have fixed itself. I haven't updated the document at all and just tried it on the local machine - the views behave as expected. I suspect it might be a proxy server being clever. I hadn't tried a straight HTTP request outside of Futon, but that was a great suggestion that I would have told me if the proxy was getting in the way (the non-Futon request wouldn't have been cached). I'll accept your answer. Thanks! – Hellfire May 18 '12 at 00:23
  • Yep just confirmed it - using the view outside of Futon works perfectly. - also tried it on a non-proxied connection and that also worked. I think the proxy is caching something it's not supposed to. Thanks again! – Hellfire May 18 '12 at 01:16

1 Answers1

1

Try accessing your view directly (ie. outside of Futon) to see if it behaves the same way.

Dominic Barnes
  • 28,083
  • 8
  • 65
  • 90