javascript - Getting all documents of a database in CouchDB - Stack Overflow

The get() method of the Cradle library requires me to provide an _id. CouchDB provides an _all_docs vie

The get() method of the Cradle library requires me to provide an _id. CouchDB provides an _all_docs view, but there's nothing in the Cradle documentation about this.

How can I get all documents from a single CouchDB database with Cradle?

The get() method of the Cradle library requires me to provide an _id. CouchDB provides an _all_docs view, but there's nothing in the Cradle documentation about this.

How can I get all documents from a single CouchDB database with Cradle?

Share Improve this question edited Aug 15, 2013 at 7:46 Octavian Helm 39.6k19 gold badges99 silver badges102 bronze badges asked Sep 30, 2012 at 15:51 user1684434user1684434 491 silver badge2 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Cradle provides an all() method which acts on a database. It queries the _all_docs view and returns the results.

It should look something like this.

var cradle = require('cradle'),
    db = new(cradle.Connection)().database('your-db');

db.all(function(err, res) {
    if (err) {
        console.log('Error: %s', err)
    } else {
        console.log(res);
    }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745451513a4628292.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信