How to add local javascript function libraries


We need to do murmurhash in map functions of views.

Could we find a common place to put the function instead of putting this long function in every map function?

Thanks and happy new year!



I believe at the moment there’s no other place you can put Javascript code other than the map / reduce functions. In general people have pretty small functions, but yes I can see in your case it may make sense to be able to have common library code…

Note that query performance is pretty dependant on the complexity of the map / reduce functions, so if it’s possible to pre-calculate the Murmur hash (for example you’re just hashing a subset of the fields) it may be worth doing that from the client and storing in the document…