The bulk document update procedure is similar to the insertion procedure, except that you must specify the document ID and current revision for every document in the bulk update JSON string.
For example, you could send the following request:
POST http://couchdb:5984/recipes/_bulk_docs Content-Type: application/json { "docs" : [ { "_id" : "FishStew", "_rev" : "1-9c65296036141e575d32ba9c034dd3ee", "servings" : 4, "subtitle" : "Delicious with freshly baked bread", "title" : "Fish Stew" }, { "_id" : "LambStew", "_rev" : "1-34c318924a8f327223eed702ddfdc66d", "servings" : 6, "subtitle" : "Serve with a wholemeal scone topping", "title" : "Lamb Stew" }, { "_id" : "7f7638c86173eb440b8890839ff35433" "_rev" : "1-857c7cbeb6c8dd1dd34a0c73e8da3c44", "servings" : 8, "subtitle" : "Hand-made dumplings make a great accompaniment", "title" : "Beef Stew" } ] }
The return structure is the JSON of the updated documents, with the new revision and ID information:
[ { "id" : "FishStew", "rev" : "2-e7af4c4e9981d960ecf78605d79b06d1" }, { "id" : "LambStew", "rev" : "2-0786321986194c92dd3b57dfbfc741ce" }, { "id" : "7f7638c86173eb440b8890839ff35433", "rev" : "2-bdd3bf3563bee516b96885a66c743f8e" } ]
You can optionally delete documents during a bulk update by
adding the _deleted
field with a value of
true
to each docment ID/revision combination
within the submitted JSON structure.
The return type from a bulk insertion will be 201, with the content of the returned structure indicating specific success or otherwise messages on a per-document basis.
The content and structure of the returned JSON will depend on the transaction semantics being used for the bulk update; see Section 5.9.3, “Bulk Documents Transaction Semantics” for more information. Conflicts and validation errors when updating documents in bulk must be handled separately; see Section 5.9.4, “Bulk Document Validation and Conflict Errors”.