官术网_书友最值得收藏!

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.

  1. Make sure you have the document open in your browser.
  2. Note the value of _rev in your document.
  3. Double-click the value of the location field: Seattle, WA, and change it to New York, NY.
  4. Click on Save Document at the top of the page.
  5. 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.

主站蜘蛛池模板: 吴堡县| 广水市| 合水县| 成安县| 榆社县| 冀州市| 锡林浩特市| 微山县| 平阴县| 合肥市| 略阳县| 永安市| 久治县| 兴文县| 永丰县| 南投市| 新邵县| 察哈| 安化县| 高清| 三江| 鹰潭市| 安塞县| 明光市| 岳池县| 沁水县| 东明县| 西安市| 垣曲县| 葫芦岛市| 枞阳县| 德格县| 格尔木市| 勃利县| 饶平县| 赫章县| 花莲县| 满城县| 扎兰屯市| 莆田市| 嵊州市|