Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 33459 invoked from network); 29 Jan 2009 18:20:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Jan 2009 18:20:06 -0000 Received: (qmail 7929 invoked by uid 500); 29 Jan 2009 18:20:04 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 7900 invoked by uid 500); 29 Jan 2009 18:20:03 -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 7889 invoked by uid 99); 29 Jan 2009 18:20:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jan 2009 10:20:03 -0800 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=FS_REPLICA,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.68.5.9] (HELO relay00.pair.com) (209.68.5.9) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 29 Jan 2009 18:19:56 +0000 Received: (qmail 86528 invoked from network); 29 Jan 2009 18:19:33 -0000 Received: from 96.33.90.152 (HELO ?192.168.1.195?) (96.33.90.152) by relay00.pair.com with SMTP; 29 Jan 2009 18:19:33 -0000 X-pair-Authenticated: 96.33.90.152 Message-Id: <91CE1D9D-2D5A-40BA-8D20-D24559BBA0F0@apache.org> From: Damien Katz To: user@couchdb.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: Trouble with replication Date: Thu, 29 Jan 2009 13:19:33 -0500 References: <20090128153026.GA12384@uk.tiscali.com> <6C6796D4-1766-4526-A9C1-A4872C935337@gmail.com> <20090128162332.GA13801@uk.tiscali.com> <20090128165433.GA14192@uk.tiscali.com> <20090128184531.GA15706@uk.tiscali.com> <9C0E9C8B-C783-47DE-8504-2CDC98650D99@apache.org> <20090129090318.GB6509@uk.tiscali.com> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org On Jan 29, 2009, at 12:50 PM, Chris Anderson wrote: > On Thu, Jan 29, 2009 at 1:03 AM, Brian Candler > wrote: >> can validate_doc_update also modify the data being stored? > > No. Side effects in that function become would deeply confusing, as it > runs during replication as well as for client-updates. > Indeed. My thinking to fill in the gap is we will provide something like a server side stored procedure, that when given a newly updated document can modify it and perform complex logic on it and then save it. Then custom validation functions would refuse any documents that aren't correctly processed, but allow through correctly process replicated edits. So you'd have a design doc that looks something like this { id:"_design/foo", procs:{ update_article: "function(editDoc, userCtx) {var prevDoc = load_prev_rev(editDoc); add_diffs(editDoc, prevDoc}; save(editDoc)}" }, validate_doc_update: "function(newDoc, oldDoc, userCtx) {if ! validate_diffs(newDoc)) {throw {forbidden: 'Documents must be saved via update_article'}", ... } And when saving a new doc: PUT /db/_proc/foo/update_article { _id:"somedocid", _rev:"somerev", yadda:"yadda", ... } -Damien