Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 57708 invoked from network); 6 Aug 2009 15:54:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Aug 2009 15:54:02 -0000 Received: (qmail 67773 invoked by uid 500); 6 Aug 2009 15:54:08 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 67685 invoked by uid 500); 6 Aug 2009 15:54:08 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 67675 invoked by uid 99); 6 Aug 2009 15:54:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2009 15:54:08 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jchris@gmail.com designates 209.85.212.193 as permitted sender) Received: from [209.85.212.193] (HELO mail-vw0-f193.google.com) (209.85.212.193) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2009 15:53:58 +0000 Received: by vws31 with SMTP id 31so914316vws.28 for ; Thu, 06 Aug 2009 08:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=Gf3+Vmr1yp0aJ72G3ztyrEDGENVqYN1J1WFNVJaTKtE=; b=XOSu0jPhHUvRexfxuuoQ9cy2mA/1WSMaua9pQWBVqHoAnj54Lyeqtx4WsTaCYRI8gH 4awrLRm4xrN2HU+EbK5gmm0aNeKRgXZOYAXi2STKnz2ZT499Mpv8ndQTlxqjRCe4En7L /eCGysDXqHGtG6Nu7GSMswpMcXY3VKdfPfqjc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=Mw7J9gfxbUaOC+pbhsJpff8b7ly3RWc4c/8JvN7QXXnjA0VNye2tkX1huT5UpHZ5Wu vYMqkMu9L2iqIkyJl/EvYC8ngQuUe3P0hDREtwobj6bAUTZpy7kkQYM733igdP+9tF2U jzSD8fDWG045AKOn5K4vtIaZHGIjznYNFlN/8= MIME-Version: 1.0 Sender: jchris@gmail.com Received: by 10.220.85.6 with SMTP id m6mr46087vcl.69.1249574015707; Thu, 06 Aug 2009 08:53:35 -0700 (PDT) In-Reply-To: References: Date: Thu, 6 Aug 2009 08:53:35 -0700 X-Google-Sender-Auth: e34ca763e25aaac5 Message-ID: Subject: Re: sorted documents by their position From: Chris Anderson To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Aug 6, 2009 at 6:21 AM, didier lafforgue wrote: > hi all, > > I'm having fun time with couchdb but I'm stuck with a simple problem: > documents sorted by their position. Actually, I've documents called proje= cts > described like this: > > { > =A0_id: "first_project", > =A0 name: "my first project", > =A0 description: "lorem ipsum ...", > =A0 type: "project" > } > > > { > =A0_id: "second_project", > =A0 name: "my second project", > =A0 description: "lorem ipsum ...", > =A0 type: "project" > } > > And I'd like to sort them using a drag&drop ui. So, I thought about addin= g a > new field (named position) and then updating their position field once I > dragged one of them. You get the picture. > Unfortunately, partial updates do not seem to exist in couchdb and I do n= ot > like the fact to save ALL my documents to update their positions, especia= lly > when I have hundred or thousand of projects. If you store the position as a float (or a string) then you only have to update the position on the changed document, not all of the docs in the list. Eg, if you want project P to come between projects B and C, then average the positions of B and C and make that the new position of P. > I came with an idea: denormalize the position field and create a document > storing the positions (just an array field with project ids) so that I do > not have to update all my documents but just the positions document. My o= nly > concern is that I'm unable to sort my projects with a couchdb view (I've = to > do it in the server side which is dirty). > > Is there a clean way to solve my problem ? > Thanks guys ! > > =A0Didier > --=20 Chris Anderson http://jchrisa.net http://couch.io