Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 76047 invoked from network); 5 Feb 2009 14:33:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Feb 2009 14:33:57 -0000 Received: (qmail 18873 invoked by uid 500); 5 Feb 2009 14:33:55 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 18840 invoked by uid 500); 5 Feb 2009 14:33: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 18824 invoked by uid 99); 5 Feb 2009 14:33:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2009 06:33:55 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of matt.goodall@gmail.com designates 209.85.128.189 as permitted sender) Received: from [209.85.128.189] (HELO fk-out-0910.google.com) (209.85.128.189) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2009 14:33:48 +0000 Received: by fk-out-0910.google.com with SMTP id f40so263857fka.11 for ; Thu, 05 Feb 2009 06:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=WlyCF8SPGPGqE66zFf0AFSYWu7TlwiScH610RM3OsVk=; b=HScTpRTf7jjRaBcozcXdTzgbxJTY3e7+rKgLkIaZ7jKNI79Czbs6R9AuJFdClcaaad 3kA8+A8jaSmryM91MnuBBe0UlrETCTFm087e1KkjvxAqjgNYQ684j86J/P1vCl6HYm/+ P4U/27RS1eMWmaAxuKpXx4u3cV+MiQE7Z6cIw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=mGk9kNLAGVrK8QN77HR7YralJbumchPHTH0ARgeq+AVbtzZSN6/Ec/pXLDXxo4vlCN 5j/N8tEqMGENU8YUcuuWoM+8Nqrmbxapj30nj4epKnFc2j7KpOFBLeGpZzVx4qmPtPl3 1EDPgoq5TQaT8vfHe9zkK/a1WgP5wFNKPuV1s= MIME-Version: 1.0 Received: by 10.181.159.11 with SMTP id l11mr181311bko.186.1233844407000; Thu, 05 Feb 2009 06:33:27 -0800 (PST) Date: Thu, 5 Feb 2009 14:33:26 +0000 Message-ID: <214c385b0902050633gac8a0b4g9c52f98de85d1c70@mail.gmail.com> Subject: Reduce to nothing From: Matt Goodall To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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