couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <janlehna...@googlemail.com>
Subject Re: nested docs / comments view
Date Fri, 29 Feb 2008 08:58:05 GMT
Hi,
On Feb 29, 2008, at 05:40, Brad Anderson wrote:
>
> It just doesn't feel right to have the parents keep track of its  
> children's ids, for chance of orphaning, maint. nightmares, and  
> more.  Who knows, maybe it's a better approach.  Even if I take that  
> route, when iterating thru the children of a doc, how do I  
> recursively call the function?  Can there be subfuns in Javascript  
> (well, CouchDB views)?


For the threaded discussion demo I did, I saved all the parent  
document ids in the child document. If you create a view indexed on  
the parent list (and a timestamp) you get a nice threaded threaded  
list of documents. Finally with a bit of startkey= and enkey=  
trickery, you can limit it down to "one parent and all its children".

This is obviously not very friendly towards changes to the tree  
structure where you move nodes and/or subtrees, but that is still  
possible.

Cheers
Jan
--

Mime
View raw message