incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wout Mertens <wout.mert...@gmail.com>
Subject Re: equivalent of JOINs in couchdb?
Date Tue, 17 Mar 2009 07:08:42 GMT
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.

Wout.

Mime
View raw message