Cloudant Fundamentals : The _rev token

The basics of CouchDB-style revision system that make the database unique (part 3 of 10)

Glynn Bird
May 22, 2018 · 3 min read
Lots of trees and branches here, just like you could have when dealing with CouchDB _rev tokens. Photo by Sergei Akulich on Unsplash

What is the _rev token?

The _rev token consists of two parts separated by a hyphen character -:

  • a 32-character string that is a cryptographic hash of the document’s body.

Why does Cloudant have a _rev token?

The _rev token keeps track of the revisions that a document goes through in its life:

  1. Second revision 2–524e981baaeec9bbecf92c4c01242308
  2. Third revision 3-e95ca5ca4dc5407fd09b8e0e0acf25fd
A simple revision tree.

Can I use the revision tree as a version control system for my documents?

No.

Deleting a document creates another revision

A Cloudant document can never really be deleted. When you do a delete API call another revision is added to the end of the tree:

  1. Second revision 2–524e981baaeec9bbecf92c4c01242308
  2. Third revision 3-e95ca5ca4dc5407fd09b8e0e0acf25fd
  3. Fourth revision 4-d0b8f4e0375c952eb957de7dc1947aef

I don’t care about revision tokens — make them go away

You can’t really make revision tokens go away, but there are libraries aimed at new starters that hide them from you so you can get on with building your app. Take a look at cloudant-quickstart which does just that.

Next time

In the next part we’ll take a look at using Cloudant’s HTTP API using the curl command-line tool.

IBM CODAIT

Things we made with data at IBM’s Center for Open Source Data and AI Technologies.

Glynn Bird

Written by

Developer @ IBM. https://glynnbird.com

IBM CODAIT

Things we made with data at IBM’s Center for Open Source Data and AI Technologies.