couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <N.Breun...@vpro.nl>
Subject Gathering data through recursive references
Date Wed, 16 Dec 2009 15:21:25 GMT
Hallo all,

I have written a couple of CouchDB map functions by now, which are being 
used in production. All is fine there. The documents in my database are 
JSON-serialized objects from a Java application. And I think I have come 
to a point where this setup is breaking down.

I'll try to simplify my problem as much as possible. I have two types of 
documents: group documents with type:"group" and program documents with 
type: "program". Programs can be episodes of groups, and groups can be 
members of other groups.

A bare-bones program document might look like this:

----
{
     "_id": "program:101",
     "_rev": "3-4139e2a50b76a736b676475f960596c0",
     "episodeOf": [
         {
             "position": 26,
             "reference": "group:3"
         }
     ],
     "type": "program"
}
----

The referenced group document might look like this:

----
{
     "_id": "group:3",
     "_rev": "1-0e7eff25b91e1e5d93ca19655c2afa69",
     "memberOf": [
         {
             "position": 1,
             "reference": "group:1"
         }
     ],
     "type": "group"
}
----

And the group document referenced in the above group document might be:

----
{
     "_id": "group:1",
     "_rev": "1-1899b6390756e2f121efbd85a04ea137",
     "type": "group"
}
----

Now I need to gather all the program data for a group (say, all programs 
that are an episode of 'group:3' or 'group:1'). Does this require 
chained map/reduce (which is not in CouchDB yet, but seems to come up 
more and more on this mailinglist) or is there another way to do this?

Nils.

Mime
View raw message