couchdb

Update a large set of documents


Is there any way in couchdb to update all documents matching certain conditions? (e.g. create new fields and set values to something based on other data in the document)

I realize that if "new" data can be functionally derived from existing data, then technically you can accomplish this via new views w/o changing the documents, but I need to update a few thousand documents with essentially the same operation.


Solution

  • You can use the bulk docs api: http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API but you will need to have all the docs first, and submit them back.

    or a doc update handler: http://wiki.apache.org/couchdb/Document_Update_Handlers but you at least need to know a list of doc ids, and do one request per id.

    Either way, there is nothing like sql where you can issue an update/where statement.