Object Commando languages, development and design


Getting Specific Document Revisions with Clutch 0.2.4

I had intended to get this out last week, but didn't quite make it. On 2/3/2011, version 0.2.4 of Clutch. One of the new features is support for getting a specific revision of a document. The code to do that looks like:

(clutch/get-document document-id {:rev revision-id} #{:rev})

The call to get a specific revision is the same as getting the most recent version except for the two extra paramters to the get-document function. The first is {:rev revision-id} and is a query-paramter map that Clutch uses when asking CouchDB for the document. In the example above, I'm asking CouchDB for a document with document-id document-id and a revision of revision-id. Typically when sending query paramters to CouchDB, you want to JSON encode them, however there are some special built-in CouchDB paramters (such as revision) that you do not want to encode using JSON. The last argument is #{:rev}, telling Clutch to not encode the :rev keypair in the query map. The third argument above can be any function that determines which revision to exclude.

CouchDB 1.0.1

Included in this release is changes needed for the Clojure view server to work with CouchDB 1.0.1 (thanks Tunde!). Previously, attempting to use the Clutch view server with the latest version of CouchDB would result in server side timeouts calling to the Clutch view code. For more information on setting up the Clojure view server see the README.

Tagged as: , No Comments