From couchdb-user-return-1368-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Thu Sep 25 16:29:14 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 12605 invoked from network); 25 Sep 2008 16:29:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Sep 2008 16:29:14 -0000 Received: (qmail 99670 invoked by uid 500); 25 Sep 2008 16:29:11 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 99646 invoked by uid 500); 25 Sep 2008 16:29:11 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 99635 invoked by uid 99); 25 Sep 2008 16:29:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2008 09:29:11 -0700 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 jchris@gmail.com designates 209.85.217.19 as permitted sender) Received: from [209.85.217.19] (HELO mail-gx0-f19.google.com) (209.85.217.19) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2008 16:28:07 +0000 Received: by gxk12 with SMTP id 12so7512976gxk.12 for ; Thu, 25 Sep 2008 09:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=77PfMg5oLF2Fqi2u13TB0XR3CcLBTXhBmpTOGWwJQsU=; b=BZVbNLOxiJo/y3YedM+kH28UCEuCGOnueAt1G7H7hLj0uCQZySAQAdwzSFB/wtPf+D VL5KJ6Aha3wW0TCNBsL4TfnOj8MaYK90ebOs8Wmu8q2nk8k6i+OV9yRUfO+LqDw6p8sc ucLXt9ZSV6OvWdBeqsewJlJvr32IzYWun9nwg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=LeeAV8n5maKN2u8Lb5WKQcM6QwrhhPSCi88kHzz3yJnSncUN6dGi0WrfORkrTUAf8s ehTyvLYxAKC3AV20qruoIhRXJ+xwroxt7V0a4H/q1xnfBNXyPVKOrLBSP6TCDKGzIAu9 +QfOr5LBQf4jOZFH9b2a2hF7SM7eJdmuTV4wk= Received: by 10.142.174.18 with SMTP id w18mr3223087wfe.202.1222360060638; Thu, 25 Sep 2008 09:27:40 -0700 (PDT) Received: by 10.142.49.15 with HTTP; Thu, 25 Sep 2008 09:27:40 -0700 (PDT) Message-ID: Date: Thu, 25 Sep 2008 09:27:40 -0700 From: "Chris Anderson" Sender: jchris@gmail.com To: couchdb-user@incubator.apache.org Subject: Re: Extending main.js In-Reply-To: <7db9abd30809250832m559f878wcf46d888c3235c4d@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <7db9abd30809250832m559f878wcf46d888c3235c4d@mail.gmail.com> X-Google-Sender-Auth: 0f154bc5345dcae9 X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Sep 25, 2008 at 8:32 AM, kowsik wrote: > I'm thinking we should > have a REST method to add additional app-specific methods that are > available to the map/reduce function? These could be utility methods > or static lookup tables and so on. The danger with this approach is that you absolutely need the source code for each map and reduce function to correspond 1-1 with its behavior. Otherwise, behavior could change without expiring the view indexes. I wrestled with the problem for while, before I realized that there's no harm in including library code directly into maps and reduces. I've got some scripts in the CouchRest project that upload filesystem code to design documents, inlining the contents of a lib.js file into your maps or reduces, if you include a comment like //include-lib within your function. This way I don't repeat myself, but each map and reduce function contains its full specification. CouchRest is located here: http://github.com/jchris/couchrest/tree/master Once you've installed the gem, run couchview --help generate to get a feel for the directory structure it's looking for. -- Chris Anderson http://jchris.mfdz.com