简体   繁体   English

CouchDB列表函数抛出TypeError(点未定义)

[英]CouchDB list function throwing TypeError (point is undefined)

I am attempting to get a list out of my database. 我正在尝试从数据库中获取列表。 The documents look like: 这些文档如下所示:

{
"class": "lists",
"collection": "symptoms",
"order": "6",
"en": "Headache",
"_id": "9022034e7d5ecd0efab0762c5b7f0c04"
}

There are an arbitrary number of "collection"s. 有任意数量的“集合”。

A view function simply returns a bunch of objects in the class "lists": 视图函数只是在“列表”类中返回一堆对象:

// Emit lists
exports.viewlist = {
  map: function(doc) {
    if (doc.class === 'lists') {
        emit(
            doc.collection, {
                order: doc.order,
                name: doc.en
            });
    }
  }
};

I wrote a list function to try to filter the output to just the list that I want. 我写了一个列表函数来尝试将输出过滤到我想要的列表。

exports.viewlist = function(head, req) {
  var row;
  start({
    code: 200,
    headers: {
        'Content-Type': 'text/json; charset=utf-8',
  }
});
while (row = getRow()) {
    if (row.collection === req.l) {
      send(JSON.stringify(row.value));
    }
  }
};

CouchDB throws an error when I visit the URL of the list: 当我访问列表的URL时,CouchDB引发错误:

http://localhost:5984/dev/_design/emr/_list/viewlists/viewlist?l=symptoms

{"error":"TypeError","reason":"{[{<<\"message\">>,<<\"point is undefined\">>},     
{<<\"fileName\">>,<<\"/usr/share/couchdb/server/main.js\">>},  
{<<\"lineNumber\">>,1500},\n  {<<\"stack\">>,
<<\"(\\\"_design/emr\\\",[object Array],
[object Array])@/usr/share/couchdb/server/main.js:1500\
()@/usr/share/couchdb/server/main.js:1562\
@/usr/share/couchdb/server/main.js:1573\
\">>}]}"}

I can't figure out where I'm going wrong here. 我不知道我要去哪里错了。

I also ran into this error and what causes it, as hinted at by @Pea-pod here Submitting form to couchDB through update handler not working , is not defining properly your exports in the couchapp's design documents. 我也遇到了这个错误,并且是由@ Pea-pod提示的原因。在这里,通过更新处理程序将表单提交到ouchDB不能正常工作 ,并没有在沙发应用程序的设计文档中正确定义您的exports In our case it was as list function that couldn't be called and instead displayed a 500 error with Type error and point is undefined in the couchdb log. 在我们的例子中,它不能作为列表函数调用,而是显示500错误和Type error并且在ouchdb日志中point is undefined

We use kanso and in the app.js we hadn't required the list file. 我们使用kanso,在app.js中我们不需要列表文件。 We had: 我们有:

module.exports = {
    rewrites: require('./rewrites'),
    views: require('./views'),
    shows: require('./shows')
};

Changing it to the following solved the problem: 将其更改为以下可以解决该问题:

module.exports = {
    rewrites: require('./rewrites'),
    views: require('./views'),
    shows: require('./shows')
    lists: require('./lists'),
};

Can I suggest to a moderator to change the title of this question to include point is undefined which is the error that shows up in the CouchDB log when this type of error is made, in order to help others find it more easily? 我是否可以建议主持人更改此问题的标题以包括point is undefined这是在发生此类错误时CouchDB日志中显示的错误,以帮助其他人更容易地找到它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery抛出未捕获的TypeError:未定义不是单击按钮时的函数 - JQuery throwing Uncaught TypeError: undefined is not a function on button click CouchDB OpenDoc函数中的jQuery TypeError - JQuery TypeError in CouchDB OpenDoc function 护照投掷“未定义不是一个功能” - Passport throwing “undefined is not a function” CouchDB在_changes上运行列表功能 - CouchDB run a list function on _changes 在沙发上调用另一个列表函数 - calling another list function in couchdb react-leaflet-heatmap-layer 抛出错误:TypeError:超级表达式必须是 null 或 function,未定义 - react-leaflet-heatmap-layer throwing error: TypeError: Super expression must either be null or a function, not undefined 在另一个函数中多次调用该函数会引发TypeError:无法读取未定义的属性“ suit” - Function being called multiple times within another is throwing a TypeError: Cannot read property 'suit' of undefined 未定义forEach TypeError:未定义不是函数 - Undefined forEach TypeError: undefined is not a function TypeError: undefined is not a function (evaluating 'this.state.list.map') - TypeError: undefined is not a function (evaluating 'this.state.list.map') 未捕获的typeError未定义不是函数 - Uncaught typeError undefined is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM