couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Copenhaver <>
Subject Re: Hierarchical comments Hacker News style
Date Wed, 16 May 2012 15:32:54 GMT
Is it not possible to maintain the scores and ordering in a document by
itself? Something like

    _id: <whatever>
    post: <post id>
    comments: {
         <top level comment id>: { score: ##, children: <comments of
similar structure> },
         <another top level comment id> : <etc>

A view could easily allow one call to CouchDB retrieve the original post
and this comment scoring doc. Then you can load whatever level of comments
you need to and know the ordering and hierarchy.

Score changes on a comment though you would need to keep updating this
document which can lead to conflicts. An update handler to increment the
score and reorder the comments will help with that and if a conflict causes
the update handler to error back to the client you just submit the same one

I have not implemented this solution myself, but throwing out ideas. I'm
certainly curious what others think is the best way.

On Wed, May 16, 2012 at 9:33 AM, Dirkjan Ochtman <> wrote:

> On Wed, May 16, 2012 at 3:19 PM, Luca Matteis <> wrote:
> > Ok. Where would it be appropriate to build such a tree? Can I do it in
> > a list function?
> > I'm using Couch directly and not interacting with it using other
> > languages, so I need Couch to do all the work.
> Should be possible to do it in the list function, but I haven't worked
> with list functions before.
> Also note that this topic is solidly off-topic for dev@, and should
> actually be discussed on user@.
> Cheers,
> Dirkjan

“The limits of language are the limits of one's world. “ - Ludwig von

"Water is fluid, soft and yielding. But water will wear away rock, which is
rigid and cannot yield. As a rule, whatever is fluid, soft and yielding
will overcome whatever is rigid and hard. This is another paradox: what is
soft is strong." - Lao-Tzu

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message