couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Metson <simonmet...@googlemail.com>
Subject Re: want to get json result from more than one document
Date Fri, 05 Nov 2010 09:45:44 GMT
Hi,
	You could use the new-ish (added in 0.11) view joins, described  
nicely in http://blog.couchone.com/post/446015664/whats-new-in-apache-couchdb-0-11-part-two-views

A view like:

function(doc) {
   if (doc.type == "blog"){
     emit(doc._id, {post: doc.body, _id:doc.author});
   }
}

is probably want you want, queried by http://127.0.0.1:5984/test/_design/blog/_view/posts?include_docs=true

Cheers
Simon

On 5 Nov 2010, at 09:22, tu wrote:

> I want to implement a blog server. I design two type of documents:  
> "Author"
> and "Blog". A "Blog" document contains a field "author_uid" to refer a
> "Author" document.
>
> I use CouchApp framework to show list of  recent posts. I find I  
> have to
> invoke couchdb server many times to show both blog body and author  
> details
> in each item.
>
> Is their and solution to return a complete json result contains full
> "Author" json object in "Blog" json object on server side?


Mime
View raw message