Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bulk fetch by ids in couchdb without creating a view

I need to fetch couchdb documents by a bunch of ids. Is there an request / API to do it ? I don't want to create a view (id, docs) and then do a find by keys. when the id b-tree already exists

like image 331
dogfish Avatar asked Dec 12 '22 12:12

dogfish


1 Answers

You should use the bulk API documented here.

It could look something like below.

  • Pass in the keys as part of the body via a POST
  • Pass in the name of the db (in the example below, it's demodb)
  • in the url, use the _all_docs for the view
  • if you want the entire documents returned (and not just the rev), be sure to pass include_docs=true

curl -d '{"keys":["docId1","docId2","docId3"]}' -X POST http://127.0.0.1:5984/demodb/_all_docs?include_docs=true

like image 155
WiredPrairie Avatar answered Feb 12 '23 09:02

WiredPrairie