incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luciano Ramalho <luci...@ramalho.org>
Subject Re: !json and !code or require()
Date Mon, 06 Dec 2010 00:14:31 GMT
On Sun, Dec 5, 2010 at 8:53 AM, Johnny Weng Luu
<johnny.weng.luu@gmail.com> wrote:
> In CouchDB definitive guide the author says you could use:
>
> // !json templates.edit
> // !json blog
> // !code vendor/couchapp/path.js
> // !code vendor/couchapp/template.js
>
> But why use those macros when you can use require()?
>
> Are there occasions I want to use the macros instead?

You must use macros for map/reduce view functions, because CouchDB
must know every change that you make to those functions, otherwise it
won't know when to update the index linked to that view. Using require
would make it possible to change the behaviour of a map function
without changing it's source code, by changing a require'd function.
Therefore we need to resort to the more primitive mechanism of
includes.

Fortunately CouchApp solves that problem for us.


-- 
Luciano Ramalho
programador repentista || stand-up programmer
Twitter: @luciano

Mime
View raw message