A utility for managing document based state machines
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
README.md
package.json

README.md

Docstate, for stately Couch stuff

A very basic state manager for document based state machines.

Usage

Here is how you would create a useless infinite loop, all serialized through a CouchDB changes feed.

var control = require('docstate').control();

control.safe("user", "new", function(doc){
  console.log(doc.type) // "user"
  doc.state = "old";
  // go save the doc
})

control.safe("user", "old", function(doc){
  doc.state = "new";
  // go save the doc
})

control.start()

mythicalChangesListener.onChange(function(info, doc){
  control.handle(doc)
})