
Time for action — updating a document in Futon
Using Futon, you can easily update the values of this document. Let's go through a quick example.
- Make sure you have the document open in your browser.
- Note the value of
_rev
in your document. - Double-click the value of the location field: Seattle, WA, and change it to New York, NY.
- Click on Save Document at the top of the page.
- Check to make sure that the value of
_rev
in your document has changed, and that New York, NY is now the value of location.
What just happened?
You just used Futon to change the value of a field in our document and then saved changes to update the document. When the document refreshed, you should have noticed that the _rev
field has changed, and your change to the field was updated.
You may have also noticed that Previous Version looks like it's clickable now. Click on it and see what happens. Futon displays the old version of the document with Seattle, WA in the location, as opposed to the new value of New York, NY.
You will now see CouchDB's revisions in full effect. If you want to, you can cycle through all of the versions of the document using the Previous Version and Next Version links.
Note
There are two important things we need to note about CouchDB's revision system:
You cannot update an old version of a document; if you try to save an old version of a document, CouchDB will return a document update conflict error. This is because the only real version of the document is the most current one.
Your revision history is only temporary. If your database kept a record of every single change, it would start to really get bloated. So, CouchDB has a feature called Compaction that will get rid of any of the old revisions.