Hi Ram, > On 12 Jun 2015, at 12:15, Ram Rachum <[email protected]> wrote:
> I want the Django app to have a database, You want Django to use CouchDB as its database? I think that's not supported officially, so that would probably mean not using the ORM and ModelForms. > ... sync the two databases together. > > Is that something that CouchDB can handle? Yes! > If so, two questions: > > 1. What happens on merge fails? (i.e. when the two masters wrote data that > contradicts each other.) I'd want to have a manual resolve, but what would > be the interface to resolving it? CouchDB doesn’t do merges, so you’ll have to resolve conflicts manually — which is good, because that’s what you want apparently ;-). CouchDB uses MVCC. It keeps both/all of the conflicting versions of a document. You resolve the conflict by removing all but one of the conflicting versions, and possibly superseding winning one with a new version. See http://guide.couchdb.org/draft/conflicts.html > 2. I'm assuming that CouchDB works by keeping a log of all transactions > made to the database. I want to provide undo functionality to the program > using this log of transactions. (i.e. every undo would look at the last > transaction and create a transaction that's the reverse of it.) This means > I need each transaction to save the old data, and I need the possibility to > access the transaction table. Is this possible? CouchDB uses an append-only file format, and a transaction replaces the previous version of a doc by a new one. The ‘transaction’ is not reversible, but if you’re lucky, the previous version of a document is still recoverable. You shouldn’t rely on this for undoing changes, though, because e.g. compaction will remove old versions, and replication won’t replicate old versions. Cheers, Roald
