couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe David Manana <>
Subject Re: use view functions to emit changes
Date Tue, 30 Nov 2010 11:22:32 GMT
Hi Benoît,

It's a good idea I think. Good work.
I have some comments regarding the patch:

1) Doing a regexp substitution of the view function's code string
seems like a recipe for disaster to me.

I think the safe and clean way to go here is to create another
sandbox, with a different 'emit' function, and in
Couch.compileFunction (utils.js) pass a third and optional argument
which is the context in which the function is going to be executed. If
omitted, it uses 'sandbox' as the context, otherwise use that other
context. Then here:

You would so something like:

fun = Couch.compileFunction(source, filter_sandbox);

2) Don't forget the indentation level for .js files is 2 spaces (I'm
seeing a mix of 4 and 2 spaces in share/server/filter.js)

3) Avoid the unnecessary white-space only changes:

4) This?LOG_INFO line is there for your debugging purposes I think
(should be removed):


On Mon, Nov 29, 2010 at 10:05 PM, Benoit Chesneau <> wrote:
> Hi all,
> Tonight i've written t quick patch that allows the user to use map
> view function to filter changes. Here is the patch :
> thoughts ?
> - benoît

Filipe David Manana,,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

View raw message