How to fetch multiple documents from CouchDB, in particular with couchdb-python?
Easiest way is to pass a include_docs=True arg to Database.view. Each row of the results will include the doc. e.g.
>>> db = couchdb.Database('http://localhost:5984/test')
>>> rows = db.view('_all_docs', keys=['docid1', 'docid2', 'missing'], include_docs=True)
>>> docs = [row.doc for row in rows]
>>> docs
[<Document 'docid1'@'...' {}>, <Document 'docid2'@'...' {}>, None]
Note that a row's doc will be None if the document does not exist.
This works with any view - just provide a list of keys suitable to the view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With