On Tue, Mar 17, 2009 at 12:38 PM, Wout Mertens <[email protected]> wrote: > On Mar 17, 2009, at 7:34 AM, Anand Chitipothu wrote: > >>> http://www.cmlenz.net/archives/2007/10/couchdb-joins >>> >> >> Thanks. That was a good article. >> >> For my understanding, let me extend the same example to a magazine >> instead of blog. >> A magazine will have issues, each issue will have posts and post will >> have comments. >> I can use the technique described in the above blog post to display >> comments in each post. >> >> What if I want to display all comments of all posts of an issue? > > > Something like > > function(doc) { > if (doc.type == "post") { > map([doc.magazine, doc._id, 1], doc); > } else if (doc.type == "comment") { > map([doc.magazine, doc.post, 2], doc); > } > } > > ? You'd need to duplicate the magazine information on the comments though.
Is it not possible to achieve that without adding magazine to each comment?
