From dev-return-4392-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Wed May 27 20:05:25 2009 Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 94307 invoked from network); 27 May 2009 20:05:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 May 2009 20:05:24 -0000 Received: (qmail 93305 invoked by uid 500); 27 May 2009 20:05:37 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 93230 invoked by uid 500); 27 May 2009 20:05:36 -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 93220 invoked by uid 99); 27 May 2009 20:05:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 May 2009 20:05:36 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=NORMAL_HTTP_TO_IP,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of b.candler@pobox.com designates 207.106.133.19 as permitted sender) Received: from [207.106.133.19] (HELO sasl.smtp.pobox.com) (207.106.133.19) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 May 2009 20:05:27 +0000 Received: from localhost.localdomain (unknown [127.0.0.1]) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id C1E5EB6AC1; Wed, 27 May 2009 16:05:03 -0400 (EDT) Received: from mappit (unknown [80.45.95.114]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 17445B6AC0; Wed, 27 May 2009 16:05:01 -0400 (EDT) Received: from brian by mappit with local (Exim 4.69) (envelope-from ) id 1M9PMy-0005cH-BD; Wed, 27 May 2009 21:05:00 +0100 Date: Wed, 27 May 2009 21:05:00 +0100 From: Brian Candler To: Jan Lehnardt Cc: dev@couchdb.apache.org Subject: Re: struggling with couchdb in production Message-ID: <20090527200500.GA21437@uk.tiscali.com> References: <2BB51A49-3A43-4404-B0A4-8EE7756AD458@apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2BB51A49-3A43-4404-B0A4-8EE7756AD458@apache.org> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Pobox-Relay-ID: AA9F2224-4AF9-11DE-963B-F6BA321C86B1-28021239!a-sasl-fastnet.pobox.com X-Virus-Checked: Checked by ClamAV on apache.org On Wed, May 27, 2009 at 07:41:54PM +0200, Jan Lehnardt wrote: > `GET /db/doc?conflicts=true` gives you a new `_conflicts` member with an > array value of all conflicting revisions (that you then have to fetch > separately). I know that - but not only do you have to ask explicitly to be told that there are conflicts, you have to fetch each one individually. > Do you mean that something like `include_docs` would be handy here? Yes. I think the default if you ask for a doc shoule be to get all versions of it, not just one arbitrary version. Here is an example of what I mean, in code. ----- 8< ----- require 'rubygems' require 'restclient' require 'json' require 'pp' DB="http://127.0.0.1:5984/test" RestClient.delete DB rescue nil RestClient.put DB, {}.to_json doc = {"_id"=>"test","hello"=>"world","_attachments"=>{ "foo"=>{"content_type"=>"text/plain","data"=>["This is a test"].pack("m").chomp}, "bar"=>{"content_type"=>"text/plain","data"=>["This is unchanged"].pack("m").chomp}, }} RestClient.post("#{DB}/_bulk_docs", {'docs'=>[doc],'all_or_nothing'=>true}.to_json) doc["_attachments"]["foo"]["data"] = ["This is change"].pack("m").chomp RestClient.post("#{DB}/_bulk_docs", {'docs'=>[doc],'all_or_nothing'=>true}.to_json) # Problem 1: how to retrieve all conflicting versions of a document quickly? # Best I can do is this: docs = [] res = RestClient.get("#{DB}/test?conflicts=true") doc = JSON.parse(res) more_revs = doc.delete('_conflicts') docs << doc more_revs.each do |rev| docs << JSON.parse(RestClient.get("#{DB}/test?rev=#{rev}")) end pp docs # (Note: if you misspell 'conflicts' then it is silently ignored) # Problem 2: now you have the conflicting versions, how do you tell which # of the attachments is different, without downloading them all? ----- 8< ----- Regards, Brian.