Get document id of all documents in couchdb database

I have a simple question: how do I get the document identifiers of all documents from this database in couchdb.

I wrote this code that retrieves all documents -

docs=CouchRest.get("http://localhost:5984/competency1/_all_docs?include_docs=true") puts docs.to_json 

The above code displays all the database information. I want to be able to list only document identifiers.

I really appreciate your help.

Thanks.

+4
source share
1 answer

From the HTTP API to retrieve all documents:

To get a list of all documents in the database, use the special _all_docs URI .... Will return a listing of all documents and their revision identifiers ordered by DocID (case sensitive)

In other words, get /competency1/_all_docs without the ?include_docs=true . This is the best solution for several reasons.

  • As well as viewing the map / reduction, it supports the options limit , startkey, endkey`.
  • But, unlike the map / reduce view, it does not use any additional disk space or processor.
  • Other people (or you in the future) will immediately recognize the purpose of this request.
+10
source

All Articles