Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 27760 invoked from network); 20 Jul 2009 05:16:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Jul 2009 05:16:45 -0000 Received: (qmail 16006 invoked by uid 500); 20 Jul 2009 05:17:50 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 15921 invoked by uid 500); 20 Jul 2009 05:17:50 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 15911 invoked by uid 99); 20 Jul 2009 05:17:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jul 2009 05:17:49 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jchris@gmail.com designates 209.85.212.176 as permitted sender) Received: from [209.85.212.176] (HELO mail-vw0-f176.google.com) (209.85.212.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jul 2009 05:17:39 +0000 Received: by vwj6 with SMTP id 6so1958197vwj.13 for ; Sun, 19 Jul 2009 22:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=036uslQ67XJ00SKsgWGx2byudKfePaCaT6y9aaxng0o=; b=jL1ml0nRUdcSiQcA/FaqeFt8o9T/yx5JW4+jPhcO/SJkUwFt66HqbbWXUxos4Eve+v aoRa+E6KZe200SnusbmyXUkzBZbJ2eA5pYnVhgwsFyyqRJpEB4GGSx30mS2D3K6IAz68 2j3WNd5k+VDo+8SPElJGhOtEXhZFnBa2Rndgo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; b=DKHmrUG7vWb1KHcfN1LjQcVlkB2YW2zWzIr0Qcw6v+F4JY5cs0vabfy6sGDeCaYUNy J1EU+3g6p0TmfC0uTu/qH5Kle+ytRlHsp5hArwHKNQAW1Fh2vuW3sh5MxxxxZmrkVAhi KkCtgAtAvHH7Fn1RJjb6WLH3MfjCHtzw2vHSg= MIME-Version: 1.0 Sender: jchris@gmail.com Received: by 10.220.85.6 with SMTP id m6mr5209405vcl.69.1248067038252; Sun, 19 Jul 2009 22:17:18 -0700 (PDT) Date: Sun, 19 Jul 2009 22:17:18 -0700 X-Google-Sender-Auth: 9b73b0fbd8f4f7ed Message-ID: Subject: filter for _changes From: Chris Anderson To: dev@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Devs, I've just committed a patch (r795687) that adds the ability to filter _changes requests with a JavaScript function. The function signature is: function(doc, req, userCtx) { return (true or false); } When it returns true (or something truthy, like a non-empty string or a non-zero number), the change is passed along to the user, otherwise it is skipped. The filter functions are stored on design documents under the "filters" field. The current best source of documentation is the changes.js test. To query changes with a filter, the syntax is like: GET /db/_changes?filter=ddocname/filtername The biggest problem with this patch is that it uses a JavaScript OS process per connected filtered listener. Fixing this is an optimization as it won't effect the API, which is why I'm comfortable committing this. I'd appreciate some review to make sure the implementation is on the right track. Cheers, Chris -- Chris Anderson http://jchrisa.net http://couch.io