CouchDB映射中有哪些JavaScript函数可用,并减少视图函数? [英] What JavaScript functions are available in the CouchDB map and reduce view functions?
问题描述
在JavaScript中为CouchDB编写map和reduce视图函数时,有哪些可用的内置函数?
When writing map and reduce view functions for CouchDB in JavaScript, what are the build-in functions available?
例如,各种示例涉及以下2个函数: emit(键,值)
和 sum(values)
。还有其他功能,如 avg(值)
可用吗?
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?
推荐答案
我不知道CouchDB的内部结构,但是,通过阅读源代码,看起来地图函数是< a 已评估 https://github.com/apache/couchdb/blob/trunk/share/server/loop.js#L16\"rel =nofollow> init_sandbox()
。因此可用的全局函数是您看到的添加到它的函数。例如:
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:
require()
log()
isArray()
sum()
- ...
_sum
和 _count $ c $相反,使用Erlang编写的内置缩减功能,你只能按原样使用它们。
_sum
and _count
, instead, are built-in reduce functions written in Erlang, and you can only use them as-is.
这篇关于CouchDB映射中有哪些JavaScript函数可用,并减少视图函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!