gpt4 book ai didi

javascript - 获取表达式的 couch db 中的列表函数未计算为函数错误

转载 作者:行者123 更新时间:2023-11-30 17:26:31 25 4
gpt4 key购买 nike

我是 couchdb 的新手,我从 couchdb wiki 复制并粘贴了一个简单的列表函数,我是
在我的浏览器中获取表达式不会计算为函数错误这是我在沙发上的代码我包含了整个文档

    {
"_id": "_design/recipies",
"_rev": "44-58a0833eb8834e801ca23f6fc82c2a6a",
"language": "javascript",
"views": {
"cup": {
"map": "function(doc) {\n\tif(doc.ingredients){\n\t\tfor (ingredient in doc.ingredients){\n\t\t\tif(doc.ingredients[ingredient].cup){\n\t\t\t\tvalue = ingredient;\n\t\t\t\tkey = doc.ingredients[ingredient].cup;\nemit(key, value);}\n\t\t}\n\t}\n\n\n \n}"
}
},
"lists": {
"index-posts": "function(doc, req) {provides('html', function() {var html = '<html><body><ol>\n'; while (row === getRow()) { html += '<li>' + row.key + ':' + row.value + '</li>\n';} html += '</ol></body></head>';return html;});}"
}
}

这是我在浏览器中遇到的错误

{"error":"compilation_error","reason":"Expression does not eval to a function. (function(doc, req) {provides('html', function() {var html = '<html><body><ol>\n'; while (row === getRow()) { html += '<li>' + row.key + ':' + row.value + '</li>\n';} html += '</ol></body></head>';return html;});})"}

我想知道函数有什么问题谢谢

最佳答案

您需要调用:

while (row = getRow()){

代替:

while (row === getRow()){

引号字符串中的换行符需要转义:

'<li>' + row.key + ':' + row.value + '</li>\\n'

关于javascript - 获取表达式的 couch db 中的列表函数未计算为函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24131421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com