Maintain invariants
The goal of this module is to help maintain invariants in a set of databases. This is typically used to enforce business rules inside a database or between databases.
Specifically it is targeted at CouchDB.
require 'denormalized-invariants' : type is 'subscription' : @db = db_uri invariant 'A subscription document should have a panel link'@db S filter BusinessSubscription map url = "/s/" return if docpanel?url is url doc.panel ?= doc.panel.url = url await @dbput doc return invariantstart return
These are called invariants because the goal of the operative part of the invariant is to attempt to maintain its textual description.