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 B7D1BDDF6 for ; Fri, 17 May 2013 15:39:27 +0000 (UTC) Received: (qmail 88843 invoked by uid 500); 17 May 2013 15:39:26 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 88796 invoked by uid 500); 17 May 2013 15:39: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 88788 invoked by uid 99); 17 May 2013 15:39:26 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 May 2013 15:39:26 +0000 Received: from localhost (HELO mail-lb0-f172.google.com) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 May 2013 15:39:25 +0000 Received: by mail-lb0-f172.google.com with SMTP id y6so4533241lbh.3 for ; Fri, 17 May 2013 08:39:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=VJdGUL7JeWxjLmjUgG6D+z1xxFUZKRUK6dlxO+GCzrE=; b=amZ4ElcbW/pDO0LNFQLfQ+z1VTCo4DdudYaeRO+RpXbuV6WeMIp8dmO+vjWZQ8B051 lIfBy6dOIY4/b0hFTQckYu4vMkzryMvTwyyAjno1SwM6TCv9oWJWvkidE1es8Uf/j+ES h/JZs7VnBxuon8YOTaTAlZJwc9U24A5ii2rDZGo/sat+/GLDgz1ah5a7npGyX0a4JudK CUtsn/04xOnk6BUJ4olx+w27V1uWdVf36RfK3PK/fkLs7pnWCDgwy14ZaB4LMbkhvg/C dA5IwYOtUNMNA75tJh+RUvccNSJNLkZP9U6wVpIZu/h8ahNVXMdN5ifkXPjTLtvSvDmu 0TOg== MIME-Version: 1.0 X-Received: by 10.112.141.38 with SMTP id rl6mr22627229lbb.101.1368805164301; Fri, 17 May 2013 08:39:24 -0700 (PDT) Received: by 10.112.80.132 with HTTP; Fri, 17 May 2013 08:39:24 -0700 (PDT) In-Reply-To: References: <20130516144732.0dda4bbf@svilendobrev.com> <70BAE84F-500B-4372-A81D-EABDD80B5A0B@sri.com> Date: Fri, 17 May 2013 16:39:24 +0100 Message-ID: Subject: Re: tracking changes - how to check what was deleted? From: Robert Newson To: "user@couchdb.apache.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Aha, ok, that makes more sense. oldDoc will be null in that case to match the behavior when there was never a document there, but it's definitely a debatable nuance. I'm in favor of the existing behavior but I do see your point. B. On 17 May 2013 16:31, Jim Klo wrote: > No, I think I incorrectly described the condition where this happens. > > If I first delete a doc with extra info like you illustrated, and then re= -insert the doc as new, the VDU does not get the existing delete "stub" in = my experience. If this has changed in 1.3, I'd welcome it. > > It would be useful if the VDU got the existing "deleted" document in cert= ain use cases, like a document got removed for DCMA violation - I don't wan= t it to reappear by mistake. I'd like to have the right logic in my VDU to = check the notes in the existing deleted stub before permitting the insert. = There's ways around this which I use instead, but think that if there's a s= tub that could be handed to VDU, it should. > > > - JK > > Sent from my iPhone > > On May 17, 2013, at 7:41 AM, "Robert Newson" wrote: > >> VDU does receive the 'stub', which is always a document. The term >> 'stub' can mislead people into thinking a deleted document is not an >> actual document (it is). >> >> Here I insist that deleted documents have a reason; >> >> =E2=9E=9C ~ curl localhost:5984/db1/_design/foo -XPUT -d >> '{"validate_doc_update":"function(newDoc) { if(newDoc._deleted && >> !newDoc.reason) { throw({forbidden:\"must have a reason\"}); } }"}' >> {"ok":true,"id":"_design/foo","rev":"1-ab8a8ecd8cf3de35ed7541facfb75029"= } >> >> An empty doc; >> >> =E2=9E=9C ~ curl localhost:5984/db1/bar -XPUT -d {} >> {"ok":true,"id":"bar","rev":"1-967a00dff5e02add41819138abb3284d"} >> >> I try delete with DELETE method, which just does _id, _rev, _deleted. >> >> =E2=9E=9C ~ curl 'localhost:5984/db1/bar?rev=3D1-967a00dff5e02add41819= 138abb3284d' >> -XDELETE >> {"error":"forbidden","reason":"must have a reason"} >> >> Now I delete with a PUT and a reason; >> >> =E2=9E=9C curl 'localhost:5984/db1/bar?rev=3D1-967a00dff5e02add41819138a= bb3284d' >> -XPUT -d '{"reason":"because I said so","_deleted":true}' >> {"ok":true,"id":"bar","rev":"2-6e10b3cc9ea15f6a9d81aa72aaa6e098"} >> >> And it's really deleted; >> >> =E2=9E=9C ~ curl localhost:5984/db1/bar >> {"error":"not_found","reason":"deleted"} >> >> And my reason is recorded; >> >> =E2=9E=9C ~ curl 'localhost:5984/db1/bar?rev=3D2-6e10b3cc9ea15f6a9d81aa= 72aaa6e098' >> {"_id":"bar","_rev":"2-6e10b3cc9ea15f6a9d81aa72aaa6e098","reason":"becau= se >> I said so","_deleted":true} >> >> B. >> >> On 17 May 2013 14:52, Jim Klo wrote: >>> It's a great tip, my only complaint about it is that the deleted stub d= oesn't get handed to the VDU function, unless that's changed in 1.3 >>> >>> - Jim >>> >>> >>> On May 17, 2013, at 12:04 AM, "Dave Cottlehuber" wr= ote: >>> >>>> On 17 May 2013 01:32, Randall Leeds wrote: >>>>> Actually, it's even easier than this. It is acceptable to put a body = in the >>>>> DELETE. You can store whatever fields you want accessible in your del= etion >>>>> stubs. >>>> >>>> **WIN** best tip of the month!