couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kowsik <kow...@gmail.com>
Subject Extending main.js
Date Thu, 25 Sep 2008 15:32:31 GMT
I frequently find myself writing little functions inside my reduce
function to sort the values or uniq the values. Yes, I realize that
are alternate ways to structure the key/value pairs to let couch do
the sorting for you. Currently main.js adds the "sum" method as a
utility method available during map/reduce. I'm thinking we should
have a REST method to add additional app-specific methods that are
available to the map/reduce function? These could be utility methods
or static lookup tables and so on.

The other possible hack is that main.js has a sandbox which is a
spidermonkey context. In either the map or the reduce functions, we
could do something like:

if (Object.prototype.my_cool_func == null) {
    Object.prototype.my_cool_func = function() { ... }
}

I'm sure that this will work since the "Object" is part of the sandbox
context. Thoughts?

K.

Mime
View raw message