CouchDB – Where can I find more information about build in JavaScript functions like sum()?

When starting to work with CouchDB the lack of an indepth documentation can be a bit frustrating.

If you’re wondering where JavaScript methods like “sum” used in reduce functions are described, for example, you don’t find any detailed information in the CouchDB-Wiki.

What you can do is to have a look at:

COUCHDB_HOME/share/server

There are a number of javascript files.

They contain the method definitions you’re looking for.

For my version of CouchDB (0.10.1) there is a single .js file called main.js containing the sum function definition:

sum = function(values) {
var rv = 0;
for (var i in values) {
rv += values[i];
}
return rv;
}

In newer CouchDB versions such as 0.11.0 you’ll find multiple javascript files. Just have look at them.

Kommentarfunktion ist deaktiviert