The general consensus is that this problem is more easily solved through templating/macros in your application code.
On Wed, Apr 29, 2009 at 3:27 PM, dmi <[email protected]> wrote: > Hi, All! > > I would like to suggest some way to have library functions in the javascript > (or other) views. > > Currently, if I have some structured entries and a bunch of "library" > functions to peek values from them, which are highly used in many views, I > have two possible ways: > > 1. to include the library functions in the each view; > 2. to patch couchdb's main.js and to include the library in it. > > Both ways are ugly, imho... > > I realize, it would be cool to have, say, "/_library/libname" document with > the library body. > And to have the optional parameter 'library' in the view's definition: > > {'map': 'function body', 'reduce': 'function body', 'library': ['libname', > ....]} > > so when couchdb pass the view's functions to the view server it will pass not > only 'add_fun', but also 'add_lib' command with the library body to evaluate > in the view execution environment. > > Unfortunately, I'm far from being an expert in couchdb ideology to propose > more constructive ideas about :-) > > -- > WBR, Dmi. >
