Search code examples
javascriptnode.jscouchdbcloudantcouchdb-nano

Get all doc data from Cloudant as opposed to id, key, value


Trying to query against my db to get all docs with all info. The db.list functionality gets the overview of the docs but does not return all the data for the docs. Currently have to get the high level data then loop through the rows and query each individual doc. There must be a better way...

Is there a way to get all docs with the full set of info for each doc?

getting:

{
  "id": "0014ee0d-7551-4639-85ef-778f74365d05",
  "key": "0014ee0d-7551-4639-85ef-778f74365d05",
  "value": {
    "rev": "59-4f01f89e12c488ba5b8aba4643982c45"
  }
}

want:

{
  "_id": "14fb92ad75b8694c05b98d89de6e9b2d",
  "_rev": "1-6067c00b37a18ad8bab6744d258e6439",
  "offeringId": "ae0146696d1d3a90fe400cc55a97a60e",
  "timestamp": 1464165870848,
  "srcUrl": "",
  "score": 9,
  ...
}

Solution

  • The repository you linked to for nano looks like an outdated mirror. The official repository includes documentation for db.list which also includes a params object. I would double-check your version of nano, but I would guess you already have a more recent version.

    You can simply add { include_docs: true } as the first argument to db.list and alongside id, key and value, you'll get a doc property that has the entire document.