From user-return-17129-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Tue Jul 12 03:28:14 2011 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 31AC3632D for ; Tue, 12 Jul 2011 03:28:14 +0000 (UTC) Received: (qmail 50311 invoked by uid 500); 12 Jul 2011 03:28:12 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 49934 invoked by uid 500); 12 Jul 2011 03:27:53 -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 49925 invoked by uid 99); 12 Jul 2011 03:27:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2011 03:27:50 +0000 X-ASF-Spam-Status: No, hits=2.9 required=5.0 tests=FREEMAIL_FROM,FS_REPLICA,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of zachary.zolton@gmail.com designates 74.125.82.54 as permitted sender) Received: from [74.125.82.54] (HELO mail-ww0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2011 03:27:44 +0000 Received: by wwf4 with SMTP id 4so4142589wwf.23 for ; Mon, 11 Jul 2011 20:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=uPMC9l9sZJYfnSYMBHdfTrMS13Bw/pTxpfKxKbJiHjM=; b=b8Ug9HSX2bE9/jpIvAlf+YaiRr7I4NwUjv5yU4aNoCfgVMDI0E7Zb5T3juUdR5qnms BqkrBp2FFwJJZX13vU+SZwYv+Zu3Kd/BkXGjcAlKT4mlXFzIYappKSVjngcyylpJOZRx edCSEiEU7dErTyZ93m46et+A53LUF0Q+2PSBQ= MIME-Version: 1.0 Received: by 10.227.179.196 with SMTP id br4mr868628wbb.53.1310441243168; Mon, 11 Jul 2011 20:27:23 -0700 (PDT) Received: by 10.227.32.145 with HTTP; Mon, 11 Jul 2011 20:27:23 -0700 (PDT) In-Reply-To: <1310286816.3214.10.camel@laumo> References: <1310249296.4810.9.camel@laumo> <1310286816.3214.10.camel@laumo> Date: Mon, 11 Jul 2011 22:27:23 -0500 Message-ID: Subject: Re: Replication filter ignoring deleted docs or changed values From: Zachary Zolton To: "user@couchdb.apache.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mitja, Perhaps you could record in some other field that the doc with type "bar" used to be type "foo". Then way you can filter the replication by docs where: type =3D=3D "foo" || type =3D=3D "bar" && old_type =3D=3D "foo" This should then replicate docs that change their type from "foo" to "bar". To give any better advice, I'd need to hear more concretely what you're trying to do here. -Zach On Sunday, July 10, 2011, Mitja Kleider wrote: > On Sat, 2011-07-09 at 17:26 -0500, Zachary Zolton wrote: >> Could you change your filter to something like this? >> >> function(doc) { >> =A0 return doc._deleted || doc.type =3D=3D 'foo'; >> } >> >> That way you replicate all deleted docs. > > That would work, thanks. I tried to avoid replicating millions of > deleted documents together with a few hundred documents passing the > filter. > > A solution might be this validate_doc_update function on the target > database: > > function(newDoc, oldDoc, userCtx) { > =A0 =A0if (newDoc._deleted =3D=3D=3D true && !oldDoc) { > =A0 =A0 =A0 =A0throw({forbidden: 'do not create deleted docs'}); > =A0 =A0} > } > > This way all deleted documents will be transmitted, but at least not > written if there is no previous revision. > > > The problem for changed values remains: when the source database changes > type=3D'foo' to type=3D'bar', the target database keeps the old revision > with type=3D'foo'. > > > Mitja > >