incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Melo <andrew.m...@gmail.com>
Subject Atomicity with _update handlers?
Date Thu, 19 Jul 2012 21:09:58 GMT
Hello all,

The documentation is a bit unclear on this, but basically I was
wondering what sort of atomicity guarantees exist for _update
handlers. Suppose I have documents that look like this

{ 'states' : [ { 'oldstate' : 'created', 'newstate' : 'new' } ] }

And an update handler that looks like this (probably not the exactly
right syntax)

function (doc, req) {
  // check that the requested old state equals the previous new state
  if doc.states[ len(doc.states) ]['newstate'] == req.query['oldstate'] {
     // update the document, adding a new state to the end of doc.states
  } else {
     // barf back to the user
  }
}

Is there a guarantee that concurrent requests to the same instance
can't end up with a garbled ordering of states?

Thanks,
Andrew

-- 
--
Andrew Melo

Mime
View raw message