Get the document id of all documents in couchdb database
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.
- Like a map/reduce view, it supports
limit
,startkey,
endkey` options. - But unlike a map/reduce view, it does not use any additional disk space or CPU.
- Other people (or you in the future) will immediately recognize this query's purpose.
精彩评论