Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B29A317B46 for ; Wed, 1 Oct 2014 19:04:27 +0000 (UTC) Received: (qmail 9409 invoked by uid 500); 1 Oct 2014 19:04:26 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 9349 invoked by uid 500); 1 Oct 2014 19:04:26 -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 9337 invoked by uid 99); 1 Oct 2014 19:04:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Oct 2014 19:04:26 +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 kxepal@gmail.com designates 209.85.212.173 as permitted sender) Received: from [209.85.212.173] (HELO mail-wi0-f173.google.com) (209.85.212.173) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Oct 2014 19:03:59 +0000 Received: by mail-wi0-f173.google.com with SMTP id bs8so1654068wib.12 for ; Wed, 01 Oct 2014 12:03:59 -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; bh=HccRnsI4b4+AWCXvWXoRksZsgcKPx2txmSqXD+TOiwk=; b=jZ8Lwuu7raOuvd56kOKNI9YYU13ivapYDSW/+Piuys5iEkhBtUXerLx8CiWzACB1Vj c7JGMIA31I27w0NoAAHbQD4Vqg39smuJ2FoFyuTYUq7J+fhr3NBVcyaqFmG5jGwqVigB sDM9McbJLy/tDSnEduvfVrsRFQ0fxBfcuFoIZaBjvVJCT5H1M86P8NIPFfzmaWdqEhLc tbG+8Wo8SQlY0+LmfnyTvg7nRlYqghLkDEcTWW64PAxysUQ96+DOd1Z5uoHY9ei4Pcwj u18vw4QFKok1Kzgpc2T0zTMYA3Gm9N9zAbDPeFiEXtn9sSHkYRr40fWXSZxrzdo22P44 6WGg== MIME-Version: 1.0 X-Received: by 10.194.48.44 with SMTP id i12mr64346668wjn.83.1412190239208; Wed, 01 Oct 2014 12:03:59 -0700 (PDT) Received: by 10.180.103.101 with HTTP; Wed, 1 Oct 2014 12:03:59 -0700 (PDT) In-Reply-To: References: Date: Wed, 1 Oct 2014 23:03:59 +0400 Message-ID: Subject: Re: How to store the delta between doc revisions? From: Alexander Shorin To: "user@couchdb.apache.org" Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Storing patches is good until you're in sure that no single patch will get suddenly deleted. Otherwise you could easily find all your history broken. Oblivious, but it is the thing to remember when picking this way of history management. Storing full document copies per revision is more solid solution for such case: you can easily skip or lose one or several revisions and be fine, but it also consumes much more disk space. Trade offs are everywhere, pick up the one that suites you. -- ,,,^..^,,, On Wed, Oct 1, 2014 at 10:02 PM, Eric B wrote: > I'm new to CouchDB and trying to figure out the best way to store a history > of changes for a document. > > Originally, I was thinking the thing that makes the most sense is to use > the update function of CouchDB but not entirely sure if I can. Is there > someway to use the update function and modify/create a second document in > the process? > > For example, if I have a document which contains notes for a client. > Everytime I modify the notes document (ie: add new lines or delete lines), > I want to maintain the changes made to it. If there was a way to use > CouchDB's rev fields for this, my problem would be solved, but since > CouchDB deletes non-current revs upon compaction, that is not an option. > > So instead, I want to create a "history_log" document, where I can just > store the delta between documents (as a patch, for example). > > In order to do this, I need to have my existing document, my new document, > compare the changes and write them to a history_log document. But I don't > see if/where I can do that within and update handler. > > Is there something that can help me do this easily within CouchDB? Are > there patch or json compare functions I can have access to from within a > CouchDB handler? > > Thanks, > > Eric