How to use the lib section of a design document in CouchDB 0.11

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

Following actions:

I started using couchapp to manage my project documents, and it has a really good macro for injecting javascript into the map and reducing functions before sending them to the server.

+4
source share
1 answer

You cannot call lib functions from your map or reduce a function, but you can with all the other functions of the CouchDB view server.

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

The reason you cannot use external functions in your map / reduce functions is because the function string is used for a hash in btree to represent so that changes to your document that do not affect the display / decrease of the function will not invalidate the whole index and make it regenerate.

+4
source

Source: https://habr.com/ru/post/1306842/


All Articles