Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does only one of these CouchDB views work?
    primarykey
    data
    text
    <p>I have some documents in CouchDB of type: <code>"Person"</code> and of type <code>"Account"</code>.</p> <p>For a straight list of all documents of these types I have created the following design document in <code>_design/directory_views</code>:</p> <pre><code>{ "_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 }); } })" } } } </code></pre> <p>This JSON validates on JSONLint and is accepted when saving the document in Futon's source view.</p> <p>Futon lists <code>directory_views/all_persons</code> and <code>directory_views/all_accounts</code> as expected in the dropdown. all_persons creates the correct list of documents of type <code>"Person"</code>, however <code>all_accounts</code> redirects back to the toplevel <code>All Documents</code>, and lists everything.</p> <p>Why does <code>all_persons</code> work, but <code>all_accounts</code> fail?</p> <p>PS. I've experienced this behavior on a number of design documents so far. This example <a href="http://kore-nordmann.de/blog/couchdb_a_use_case.html#a-practical-example" rel="nofollow">http://kore-nordmann.de/blog/couchdb_a_use_case.html#a-practical-example</a> shows two views in the same design document, so I don't think that you can only have one view per document.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload