4

When writing map and reduce view functions for CouchDB in JavaScript, what are the build-in functions available?

For example, various examples refer to the following 2 functions: emit(key, value) and sum(values). Are there other functions like avg(values) available?

Where can I find a full list of all functions available?

Vilmantas Baranauskas
  • 6,596
  • 3
  • 38
  • 50

2 Answers2

2

I don't know the CouchDB internals, however, from reading the sources, it looks like the map functions are evaluated in the sandbox created by init_sandbox(). So the available "global" functions are the ones you see added to it. For example:

_sum and _count, instead, are built-in reduce functions written in Erlang, and you can only use them as-is.

Marcello Nuccio
  • 3,901
  • 2
  • 28
  • 28
0

Well first: not CacheDB but CouchDB (header). Second: these are not built-in Javascript functions - these are just built-in functions which work in Erlang. As far as i know there are only _sum and _count functions available.

Dmitrii Sorin
  • 3,855
  • 4
  • 31
  • 40