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 badges1 Answer
Reset to default 7Cradle 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条)