3

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?

Octavian Helm
  • 39,405
  • 19
  • 98
  • 102
user1684434
  • 49
  • 1
  • 2

1 Answers1

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);
    }
});
Octavian Helm
  • 39,405
  • 19
  • 98
  • 102