我使用的是 Couchdb 1.6.1。我有一个测试
设计内部的节目。
{
"select": {
"map": "function(a){emit(null,a._id)}"
}
}
我正在使用 Nano
Node 模块与数据库交互。当我运行下面的 js 文件时 { Error: Expression does not eval to a function. ([object Object])
返回错误消息。
this.database.show('test', 'select', 35435156453, function (error, body) {
if(error) {
console.log(error);
}
else{
console.log(body);
}
});
我尝试用括号括起来该函数,如下所示。这没用
{
"select": {
"map": "(function(a){emit(null,a._id)})"
}
}
为什么我会收到此错误?
最佳答案
首先,您使用显示函数,就好像它是 View 函数一样(这是完全不同的)。
如果您确实想使用显示“功能”,那么我建议您查看this documentation.显示函数用于以 HTML 或您需要的任何格式返回数据。您通常定义这样的显示函数:
{
"select":"function(doc,req){return 'Return your stuff here.'}"
}
您提供给我们的函数是在 View 中使用的映射函数。请参阅this link以获得更多文档。如果是这样的话,我猜你只需要使用 this.database.view()
。
关于javascript - 不等于 couchdb 中的函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39433960/