开发者

How to get a CouchDB _list result with Cradle

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 开发者_如何学Cseems 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] }


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜