views:

89

answers:

1

I want to add some custom javascript functions to my design document, I can't find any examples of how to actually add these functions to the "lib" section of a design document. Can someone show me an example of how to add a function definition to the "lib" section?

Follow up:

I started using couchapp to manage my design documents and it has a really nice macro facility for injecting javascript into map and reduce functions before sending them to the server.

+3  A: 

You can't call lib functions from your map or reduce function but you can with all the other CouchDB view server functions.

http://wiki.apache.org/couchdb/commonjs_modules

The reason you can't use outside functions in your map/reduce functions is because the string for the functions is used for hash on the btree for the view so that changes to your document that don't impact the map/reduce functions won't invalidate the entire index and force it to regenerate.

mikeal