Update Document in CouchDB

Update Document

Using Fauxton:

  • Open the following URL:
  • Click on the edit option.
  • A new page will be displayed to edit the entries in a document.
  • Click on the save changes tab after editing.
  • The document is thus updated.


Using cURL utility:


curl -X PUT -d '{ "field" : "value", "_rev" : "revision id" }'  


Retrieve the revision id of the document to be updated.

curl -X GET

Use the revision id in the below command.

curl -H 'Content-Type: application/json' \

-X PUT -d'{"Salary": "40000",  "_rev":"1-609cd49b1a1bfa5423fcb712b5a65789"}'



Verify the document updated using the below command:

curl -X GET


Important Points:

  • The database name and the document id must be present in the URL sent.
  • A field cannot be added to an existing document.
  • An entirely new version of a document can also be written in a database with the same document ID.
  • The response of the update will contain 3 fields:
    1. “ok”: It is used to specify that the operation is successful.
    2. “id”: It is used to store the id of the document.
    3. “rev”: It is used to specify the revision id. A _rev value is generated by CouchDB, every time when a document is revised (updated or modified).


Content Protection by DMCA.com