Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 86502 invoked from network); 5 Feb 2009 15:00:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Feb 2009 15:00:58 -0000 Received: (qmail 67766 invoked by uid 500); 5 Feb 2009 15:00:56 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 67332 invoked by uid 500); 5 Feb 2009 15:00:55 -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 67321 invoked by uid 99); 5 Feb 2009 15:00:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2009 07:00:55 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of michael.marks@gmx.de designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 05 Feb 2009 15:00:45 +0000 Received: (qmail invoked by alias); 05 Feb 2009 15:00:24 -0000 Received: from blueice2n1.de.ibm.com (EHLO [9.152.215.31]) [195.212.29.171] by mail.gmx.net (mp011) with SMTP; 05 Feb 2009 16:00:24 +0100 X-Authenticated: #3487131 X-Provags-ID: V01U2FsdGVkX198ZDkhh1h8QBvn8FB1JoDza8a6SeFKx1+Wj+uV9B hYeE05YQV/rl2y Message-ID: <498AFF12.6080409@gmx.de> Date: Thu, 05 Feb 2009 16:00:34 +0100 From: Michael Marks User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: Reduce to nothing References: <214c385b0902050633gac8a0b4g9c52f98de85d1c70@mail.gmail.com> <7c40ded80902050642o43770a11jc3c536feffe21604@mail.gmail.com> <7c40ded80902050644y644678cdj6be04ca8dddf1b90@mail.gmail.com> <214c385b0902050650n6a911e9cw9a0b9f86e049ea5@mail.gmail.com> In-Reply-To: <214c385b0902050650n6a911e9cw9a0b9f86e049ea5@mail.gmail.com> Content-Type: multipart/alternative; boundary="------------040402050404080102070400" X-Y-GMX-Trusted: 0 X-FuHaFi: 0.85,0.86 X-Virus-Checked: Checked by ClamAV on apache.org --------------040402050404080102070400 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit How about having a third attribute "state": with possible values "active", "cancelled" and filtering about this one? ________________________________________ Michael Marks Matt Goodall schrieb: > 2009/2/5 Jeremy Wall : > >> Can't you just have the map screen out the cancellations? Seems like that's >> the most natural spot for the behaviour you want. >> > > Nope, because the "thing" doesn't know it's been cancelled. > > - Matt > > > >> On Feb 5, 2009 8:34 AM, "Matt Goodall" wrote: >> >> Hi, >> >> Is it possible to reduce a key to nothing, i.e. completely remove a >> key from the reduction result. >> >> For instance, say you post three documents: >> >> {"_id": "thing1", "type": "thing"} >> {"_id": "thing2", "type": "thing"} >> {"_id": "...", "type": "cancellation", "cancels": "thing1"} >> >> It's trivial to produce a map function that collates the "thing" and >> "cancellation" documents. However, I can't work out how, or even it >> it's possible, to reduce the view that so that only "thing2" remains. >> >> This seems like it might be a useful thing to be able to do at times. >> For instance, posting a "cancellation" document effectively removes a >> "thing" from the database. Nothing needs to touch the "thing", >> avoiding any chance of conflicts and it doesn't matter how many >> "cancellation" documents get posted making cancellation an idempotent >> operation. >> >> I tried not returning anything, just in case it worked ;-), but got a >> JSON encoding error (can't encode undefined, iirc). That would be a >> simple approach. However, I wondered if the more "normal" approach of >> allowing a reduce function to emit zero or more (key, value) pairs >> would be even better? Not sure if that would break the incremental >> reduce though. >> >> Any ideas, or is there another way to achieve this that I'm missing? >> >> - Matt >> >> > > --------------040402050404080102070400--