Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 99291 invoked from network); 27 Sep 2009 01:25:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Sep 2009 01:25:00 -0000 Received: (qmail 92970 invoked by uid 500); 27 Sep 2009 01:24:58 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 92869 invoked by uid 500); 27 Sep 2009 01:24:57 -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 92667 invoked by uid 99); 27 Sep 2009 01:24:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Sep 2009 01:24:57 +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 hallettj@gmail.com designates 209.85.210.176 as permitted sender) Received: from [209.85.210.176] (HELO mail-yx0-f176.google.com) (209.85.210.176) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Sep 2009 01:24:47 +0000 Received: by yxe6 with SMTP id 6so4180975yxe.13 for ; Sat, 26 Sep 2009 18:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=CAsQroJ27W+gn4faPp1qu7HMC67q/J0G+8A+CQgQcDs=; b=D4pOVzSd+ioK6Nwak5xqxhebhbdZKlqT9fp2+nVU1GwbpqnaMa6S2O3XnmYqtKIzJX y4GPsPjMjqoqrf9My9D2b6aOErom70pAWCVwQUVwJNbPyGEWo4AEl5qyDtIqiuh+vxXm 7AiFvNi4CbKZIqpPbw/x3+3zu0N+lDYwSVJfY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=B1RacdUp8Slhch6oAi0L05xnMZ8QVsEd1PLXnP3fnD8o8zlkzG3HkXpL3to26pSBOS Ri0NBHdL5MZKgTO3iJbU+Wr7GB+THZdJDg7Z6TosQpf2TCPhGNztTnh5P92qMcY1SELu p4O8FabUqovwE4FH+SIKl/1Q0bIzS4kHPdtvQ= MIME-Version: 1.0 Received: by 10.151.92.9 with SMTP id u9mr5171853ybl.158.1254014666461; Sat, 26 Sep 2009 18:24:26 -0700 (PDT) In-Reply-To: References: <796695.24188.qm@web45314.mail.sp1.yahoo.com> <8a02878f0909251832n3358d3b3s4d0dfe4513917500@mail.gmail.com> <8a02878f0909251839g655b83aak3bd01ee753dc2cac@mail.gmail.com> <882214.95805.qm@web45315.mail.sp1.yahoo.com> From: Jesse Hallett Date: Sat, 26 Sep 2009 18:24:06 -0700 Message-ID: <8a02878f0909261824i83e649w4cda46739a852860@mail.gmail.com> Subject: Re: couchdb: suitable for this type of applications ? To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Sat, Sep 26, 2009 at 12:22 AM, Chris Anderson wrote: > On Fri, Sep 25, 2009 at 8:34 PM, go canal wrote: >>>>When you compact the database it removes all but the most recent versio= n of each document. >> >> >> Does this mean that if I want to support document version feature, I can= not compact the database ? >> > > Applications should not depend on controlling compaction schedules. > Only the most recent version is replicated, so if you run in a cluster > it's like it's compacting all the time. > >> Let's say I am working on a Word document, I upload it as an attachment;= I need to have a list of all versions for this file and can download any o= f previous version. >> >> Is this how I should model it in CouchDB: >> =A0- have a version field, not using the CouchDB _rev. update the versio= n in my application. >> =A0- when uploading the modified Word document, a doc with a different I= D is created. So compacting a DB will not affect them. >> =A0 =A0but how to get a list of all versions of this document ? I need t= o use another field to identify them, for example, another application gene= rated ID. >> >> Is this the general practice ? I am sure supporting versioning is a comm= on request, so appreciate if you can provide some advices.. >> thanks, >> canal That approach seems reasonable. In any case content versioning is an application level concern. CouchDB's multiple revision feature is used to detect update conflicts and to prevent race conditions. >From CouchDB: The Definitive Guide : > We touched on this in the Eventual Consistency chapter. The revision id a= cts as a > gatekeeper for writes to a document in CouchDB=92s MVCC system. A documen= t is a shared > resource, many clients can read and write them at the same time. To make = sure two > writing clients don=92t step on each others feet, each client must provid= e what it believes is > the latest revision id of a document along with the proposed changes. If = the on-disk > revision id matches the provided _rev, CouchDB will accept the change. If= it doesn=92t, the > update will be rejected. The client should read the latest version, integ= rate his changes and > try saving again. >From the CouchDB Wiki : > The include_docs option will include the associated document. Although, t= he user should > keep in mind that there is a race condition when using this option. It is= possible that > between reading the view data and fetching the corresponding document tha= t the document > has changed. If you want to alleviate such concerns you should emit an ob= ject with a _rev > attribute as in emit(key, {"_rev": doc._rev}). This alleviates the race c= ondition but leaves > the possiblity that the returned document has been deleted (in which case= , it includes the > "_deleted": true attribute). > -- > Chris Anderson > http://jchrisa.net > http://couch.io >