admin管理员组

文章数量:1425791

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);
    }
});

本文标签: javascriptGetting all documents of a database in CouchDBStack Overflow