Sean, interesting. What would be the drawbacks of this other than the conflict issue? How would I order the comments by score - would my view need to do the logic? Also, what if there's *many* comments to a post. How much can a single document handle?
Luca On Wed, May 16, 2012 at 5:32 PM, Sean Copenhaver <[email protected]> wrote: > 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 > again. > > 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 <[email protected]> wrote: > >> On Wed, May 16, 2012 at 3:19 PM, Luca Matteis <[email protected]> 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 > Wittgenstein > > "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
