I am working on a new section of my CouchDB library to synchronize a Couch database with a local array. Before I wade too far in, I wanted to get to see if my plan makes sense..
I have two questions I'm hoping for input on: 1. Can anyone think of a scenario I am missing? 2. Is there anything missing from the conflict resolution options? CouchDB uses revision numbers to keep track of changes, so I am trying to map out all the possible scenarios that should exist. quick definitions: localRev: revision number of the local document from last sync serverRev: revision number of the server document localDirty: boolean flag that says that the local document has been edited since last sync Comparing each document's rev numbers, I envision the following scenarios: 1. document is unchanged localRev = serverRev AND localDirty = false action: ignore during sync 2. server document is newer localRev < serverRev AND localDirty = false action: download latest version 3. document has been edited locally, local copy is the same as server localRev = serverRev AND localDirty = true action: upload new version 4. document has been edited locally, BUT server copy is newer localRev < serverRev AND localDirty = true action: depends on conflict resolution settings (see below) 5. local document doesn't exist localRev = empty and serverRev > 0 action: download document 6. local document is new, doesn't exist on server yet localRev > 0 and serverRev = empty action: upload document 7. The revision number is generated by the server, so there should be no reason why localRev > serverRev unless the user has switched to a different server that has been replicating with the original, and is behind. action: it's an unlikely scenario... upload local document 8. if the record is marked as deleted locally or on the server, it is deleted everywhere Conflict resolution: These are the options I am planning on for conflict resolution, they will get passed as a param in the sync function local: in conflict, keep local, discard server server: in conflict, keep server, discard local localmerge: keep local document, insert server document as a subkey in local document "conflict" servermerge: keep server document, insert local document as a subkey in local document "conflict" keepboth: rename "_id" of local document and upload it, download server version ----- --- Greg (pink) Miller mad, pink and dangerous to code -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Looking-for-advice-on-database-syncing-tp4712046.html Sent from the Revolution - User mailing list archive at Nabble.com. _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode