如何使用 Cradle 获取 CouchDB _list 结果
在 Node 中,使用 Express 和 Cradle,我对 _list 的调用不起作用。其他调用转到 _view 并且工作正常。 Cradle 文档 不包含有关 _list 的部分,但它似乎来自 此 GitHub自述文件它应该像_view一样工作。
我的代码如下所示:
if(isList){
db.list(couch_url, function (err, res) {
if(err){
console.log("error couchdb list", err);
}else{
//console.log(res);
callback(JSON.stringify(res));
}
});
}
couch_url
变量只是常规的 http 请求,看起来像: myCouch/_design/Model3D/_list/convert/All
除了路径指示符 (_design, _view、_list) 已被删除,以获取 Cradle 的 Model3D/convert/All
(看起来它们已放回 Cradle 函数中)。由 couch_url
表示的完整路径将在其他 CouchDB 连接中工作,并且正如我所说,Cradle 视图功能工作正常。
我得到的错误对象是:
{ stack: [Getter/Setter],
arguments: [ 'ILLEGAL' ],
type: 'unexpected_token',
message: [Getter/Setter] }
In Node, using Express and Cradle, I have a call to a _list that does not work. Other calls go to _view and work fine. The Cradle documentation does not include a section on _list but it seems from this GitHub readme that it is supposed to work just like _view.
My code looks like:
if(isList){
db.list(couch_url, function (err, res) {
if(err){
console.log("error couchdb list", err);
}else{
//console.log(res);
callback(JSON.stringify(res));
}
});
}
The couch_url
variable is just the regular http request and looks like: myCouch/_design/Model3D/_list/convert/All
except the path designators (_design, _view, _list) have been removed to get Model3D/convert/All
for Cradle (it looks like they are put back in the Cradle function). That full path represented by couch_url
will work in other CouchDB connections, and like I said, the Cradle view function works fine.
The error object I get is:
{ stack: [Getter/Setter],
arguments: [ 'ILLEGAL' ],
type: 'unexpected_token',
message: [Getter/Setter] }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查您正在使用的列表函数 - 它很可能会生成损坏的 JSON。
就我而言,我得到的属性结果为“未定义”。任何未定义的内容都应该被删除,并且所有属性名称都应该用引号引起来
Check the list function you are using - it is highly likely to be producing broken JSON.
In my case, I was getting a result of 'undefined' for a property. Anything undefined should be dropped, and all property names should be in quotes
我试图重现这个,但它似乎对我有用。只需仔细检查是否“转换”您的列表函数和“全部”您的视图名称?
我看到的唯一其他警告是您的数据库名称中包含大写字符。 CouchDB 数据库必须全部小写。
I tried to reproduce this, but it seems to work for me. Just double checking is "convert" your list function and "All" your view name?
The only other caveat I am seeing is that your database name has a capital case character in it. CouchDB databases must be all lowercase.