Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do partial update of a document

Tags:

couchdb

I need a guidance on how can I update a field in CouchDB. I tried curl via console it works fine but programatically. I don't understand how to update a particular field say 'name'. Here is the snippet of updating a document in CouchDB which works fine and returns me the updated revision id.

HttpPut httpPutRequest = new HttpPut(hostUrl +"/"+ docId);
StringEntity body = new StringEntity(jsonDoc.toString());
httpPutRequest.setEntity(body);

httpPutRequest.setHeader("Accept", "application/json");
httpPutRequest.setHeader("Content-type", "application/json");
like image 422
Jitesh Avatar asked Nov 09 '10 10:11

Jitesh


People also ask

What is partial update?

A partial update is a change in the overall data set that does not require restarting the MDEX Engine. Partial updates allow you to update only those portions of the MDEX Engine index that have changed since the last baseline update. A partial update lets you implement a number of the source data changes.

How do you update an existing document?

Select the document you want to edit by clicking the document name. On the Document Details page, click EDIT / UPDATE. You can see this button at the top right corner of the page only if you have Document Edit Permission. On the Edit Document page, make your changes.

Can we update data in Cosmos DB?

Change feed in Azure Cosmos DB listens to a container for any changes and then outputs documents that were changed. Using change feed, you see all updates to documents including both partial and full document updates.

How do I update my Couchdb file?

Open the Fauxton url:http://127.0.0.1:5984/_utils/ You can also update/ change/ edit your document once you created. Click on the edit option (encircled in red). After clicking, you will get a new page where you can edit your entries. After editing click on the save changes tab and your document will be updated.


1 Answers

Partial updates are not supported by CouchDB. In other words, to update a field in the document, you must update the field in your local JSON document and push that document to CouchDB as a whole.

You can accomplish this by still issuing an HTTP PUT, ensuring the appropriate _rev is included in your document.

More details are available in the wiki.

like image 139
Ryan Duffield Avatar answered Nov 02 '22 06:11

Ryan Duffield