开发者

Get the document id of all documents in couchdb database

开发者 https://www.devze.com 2023-04-07 17:26 出处:网络
I have a simple question, How should I retrieve t开发者_如何学Che document ids of all documents from a given database in couchdb.

I have a simple question, How should I retrieve t开发者_如何学Che document ids of all documents from a given database in couchdb.

I have written this code which retrieves all the documents-

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

The above code displays the entire details of the database.I want to be able to list only the document id's.

I really appreciate your help.

Thanks.


From HTTP Document API about retrieving all documents:

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

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

  1. Like a map/reduce view, it supports limit, startkey,endkey` options.
  2. But unlike a map/reduce view, it does not use any additional disk space or CPU.
  3. Other people (or you in the future) will immediately recognize this query's purpose.
0

精彩评论

暂无评论...
验证码 换一张
取 消