couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jo-Erlend Schinstad <>
Subject Re: Modeling a tree in couchdb.
Date Mon, 02 Jan 2012 08:04:14 GMT
Den 02. jan. 2012 08:58, skrev Walter Werner:
> How about if every document get a parent attribute?
> root document
> id: 123
> parent: undefined
> child document
> id: 768
> parent: 123
> child child document
> id: 991
> parent: 768
> etc.
> You need then a view with the parent as a key. With one request you
> can get all his children (only 1 level) of a document. Then you
> proceed with the children-documents and ask again whether they have
> children. Maybe it will be a performance Issue, if your 'object' has
> too many levels. The advantage is, that you don't have to think about
> how the id's of your documents should look like.

That is almost what I'm currently trying. I Have a topmost_parent 
attribute, then a parent attribute and a next_sibling attribute. That 
way, I can get all elements with one request. I still have to process on 
the client, but I think it should work. The optimal solution would allow 
me to get it ordered correctly from the database, but I see no way of 
achieving that.

Jo-Erlend Schinstad

View raw message