3

Passing null or an empty Json to the selector does not seem to work. I am trying to get all the data in a database. Tried:

 db.list({}, function (err, data) {
        if (err) {
            return console.log("Error:",err.message);
        }
        console.log(data);
    });
    db.find(null, function (err, data) {
        if (err) {
            return console.log("Error:",err.message);
        }
        console.log(data);
    });
    db.bulk({docs:[]}, function (err, data) {
        if (err) {
            return console.log("Error:",err.message);
        }
        console.log(data);
    });
Muhammad Shahzad
  • 9,340
  • 21
  • 86
  • 130
Malaka
  • 107
  • 1
  • 6

1 Answers1

8

To get a list of all the documents, don't pass anything at all e.g.

db.list(function (err, data) {
  console.log(err, data);
});

If you want the document bodies too, then pass in include_docs=true:

db.list({include_docs:true}, function (err, data) {
  console.log(err, data);
});

This mirrors the CouchDB API for the GET /db/_all_docs endpoint - without any parameters, you get all the document ids and revision tokens.

Glynn Bird
  • 5,507
  • 2
  • 12
  • 21