Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update a large set of documents

Tags:

couchdb

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.

like image 374
Jason S Avatar asked Nov 04 '11 14:11

Jason S


People also ask

How to update large documents in MongoDB?

To update large set of documents, use Bulk Write operations. The Java client (uses MongoDB Java Driver) code you write and execute submits the update query to the server, the update happens on the server and you get the result (status, number of documents updated, etc.) back at the Java client.

Which command is used to update all documents in a collection?

To update multiple documents, use db. collection. updateMany()

How do you update an entire document?

Update all fields in a documentPress Ctrl + A. Press F9. If your document has tables with fields or formulas, you might need to select each table separately and press F9.

How do I update multiple fields in MongoDB?

Update Multiple Fields of a Single Document. We can use $set and $inc operators to update any field in MongoDB. The $set operator will set the newly specified value while the $inc operator will increase the value by a specified value.


1 Answers

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.

like image 156
Ryan Ramage Avatar answered Sep 28 '22 18:09

Ryan Ramage