I am seeking a way to utilize a variety of functions across different couchdb view map functions. My attempt involves using the commonjs require pattern.
Within the given design doc, I am puzzled as to why the require statement in test1 successfully functions, while the one in test2 appears to be ineffective.
Are there alternative methods for reusing functions across multiple couchdb views?
{
"_id": "_design/app",
"_rev": "29-876296b1278db067378635a5f3309aa3",
"views": {
"test1": {
"map": "function (doc) {\n var setting1 = require('views/lib/config').setting1;\n emit(doc._id, setting1);\n }"
},
"test2": {
"map": "function (doc) {\n var fn1 = require('views/lib/sharedFunctions').fn1;\n emit(doc._id, fn1(doc));\n }"
},
"lib": {
"config": "exports.setting1 = 'a';exports.setting2 = 42",
"sharedFunctions":"exports.fn1 = function (doc) {\n return 'fn1 read doc ' + doc._id;\n }"
}
}
}
Additional information: My current approach involves utilizing the 'grunt-couchapp' plugin to handle the uploading of my design docs from my project src directories.