From dev-return-22269-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Wed May 16 16:26:03 2012 Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4D5299E47 for ; Wed, 16 May 2012 16:26:03 +0000 (UTC) Received: (qmail 94441 invoked by uid 500); 16 May 2012 16:26:02 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 94390 invoked by uid 500); 16 May 2012 16:26:02 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 94382 invoked by uid 99); 16 May 2012 16:26:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 May 2012 16:26:02 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lmatteis@gmail.com designates 74.125.82.54 as permitted sender) Received: from [74.125.82.54] (HELO mail-wg0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 May 2012 16:25:56 +0000 Received: by wgbfg15 with SMTP id fg15so847001wgb.23 for ; Wed, 16 May 2012 09:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=9iSGIIQ5aYnfI5AuOCsbCJ6Q88AE04ynjxxzGBSNMrU=; b=D+BMmoECbqkyevWdp6/y8uhw5Dxj3SFBGFG4rEIFVLtEefIb9p9KP2gd87pkjy1MuV rAQooxvW+0HwoQIMJqPGPwVT2/9+82d438TTScNzWASG9qnfwOm/0UiPj1rVyzc+zIXs EGL9X1WEhK5PIW3DsGWKZ2ovQKu+9zqaxQ07ED9srO5OrY1j/cen9+uBTYXnPeuklp3g x3u5LHcOPJfwPQwAj5X+zXLSefX1sSQBRAkWz4nANFdJaIX0gjzf5+6WNVm2BZP5EdkU RpZzeFVkRjdhxZ7UpEmyNBwj2HmIQ/Dvy+uTMJbsJxWnYlC4HId7R+PRF+henUE/Pmro qwQg== MIME-Version: 1.0 Received: by 10.216.208.151 with SMTP id q23mr2476208weo.20.1337185533415; Wed, 16 May 2012 09:25:33 -0700 (PDT) Received: by 10.194.44.135 with HTTP; Wed, 16 May 2012 09:25:33 -0700 (PDT) In-Reply-To: References: Date: Wed, 16 May 2012 18:25:33 +0200 Message-ID: Subject: Re: Hierarchical comments Hacker News style From: Luca Matteis To: dev@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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 wrote: > Is it not possible to maintain the scores and ordering in a document by > itself? Something like > > { > =A0 =A0_id: > =A0 =A0post: > =A0 =A0comments: { > =A0 =A0 =A0 =A0 : { score: ##, children: similar structure> }, > =A0 =A0 =A0 =A0 : > =A0 =A0} > } > > 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 comment= s > 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 caus= es > the update handler to error back to the client you just submit the same o= ne > 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 wro= te: > >> 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 >> > > > > -- > =93The limits of language are the limits of one's world. =93 - 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 i= s > soft is strong." - Lao-Tzu