couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikeal Rogers <>
Subject Re: JavaScript specification changes at 0.11?
Date Thu, 25 Mar 2010 19:10:31 GMT
correct, "this" is now the ddoc, so if you attach templates as attributes to
your ddoc you can pull them out with something like:


The way you were using this previously is a very very bad idea because there
are no guarantees that you won't at some point in the future be using two
query servers to return show functions for the same ddoc.

If you want to have a function that can be loaded in any view you should use
the new commonjs modules:

At this time these are not cached so they will get re-evaled each time. You
should never depend on global state in the view server because it could
always end up be distributed to parallel instances in the future.


On Thu, Mar 25, 2010 at 7:18 AM, Benoit Chesneau <>wrote:

> On Thu, Mar 25, 2010 at 3:10 PM, Paul Davis <>
> wrote:
> > The fact that you used to be able to attach to the 'this' object was
> > definitely just a coincidence. I'm fairly surprised it even worked
> > consistently for you.
> >
> > That said, it looks like you're wanting to check out the
> > require("") method that's now available for show and
> > list. This will let you define arbitrary JS in your _design doc and
> > import it in your show/list functions.
> >
> > HTH,
> > Paul Davis
> >
> this is also used to acccess to the ddoc now if I remmeber.
> - benoit

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message