user1684434
user1684434

Reputation: 49

Getting all documents of a database in CouchDB

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?

Upvotes: 3

Views: 3115

Answers (1)

Octavian Helm
Octavian Helm

Reputation: 39605

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

Upvotes: 7

Related Questions