couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Krause <jk.i...@googlemail.com>
Subject Re: Included docs in 0.11
Date Thu, 22 Apr 2010 10:09:15 GMT
Hi, I am a colleague of Moritz. The typo is only in the mail, but it was still my user error.
To make lists work with include_docs you have to access the "doc" object of the row, not the
"value" object as in other cases. This is obvious if you look at the result of a view with
include_docs. I had expected a magic replace of the value with the object and did not look
at the view output in detail ...

Here is some example code to possibly help others avoid that same mistake:

Accessing a doc in a list when the doc is emitted by the view:
	     
  provides("xml", function() {
    // loop over all rows
    while (row = getRow()) {
    	var solution = <solution/>;
        solution.title = row.value.name;  //// access with = row.value
        solution.id = row.key;

Accessing a doc in a list when the doc is included into the view with include_docs=true:

  provides("xml", function() {
    // loop over all rows
    while (row = getRow()) {
       var solution = <solution/>;
       solution.title = row.doc.name;  //// access with =  row.doc
       solution.id = row.key;

Cheers

--jo


On :Apr 21, 2010 8:45:08 am J Chris Anderson wrote:

I would like to use the result of the view in a list, e.g. get =
/db/_design/mydesign/_list/mylist/myview?key=3D"foo"&included_docs=3Dtrue

I want to be sure this isn't a basic typo. I think you mean =
include_docs=3Dtrue
(not included...) I'm pretty sure this works.=
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message