couchdb-to-mysql icon indicating copy to clipboard operation
couchdb-to-mysql copied to clipboard

prevent duplication of records in replication to mysql

Open simran66 opened this issue 7 years ago • 0 comments

I have added cvr.on events to app.js at the root of my Node JS app. I believe this would be triggered whenever there is a new insert.

  1. How do I handle insert to different tables?

Also, as I restart my node application, all records from CouchDB get replicated to MSQL including the ones that were replicated already.

  1. Did I place this event in wrong place? How do I make sure that once replicated records should not be reinserted in MySQL? Why is that happening anyway?

I am not using _id from couchDB since records that get inserted into couchDB are the ones that got created when user was offline. Rest of them are directly inserted to MySQL. I understand _id can prevent duplication if I was using it as a key, but in my case it does not seem to make sense.

My best guess is that records once inserted into MySQL should get deleted from CouchDB. Records in CouchDB are coming from PouchDB.

What is the right way to handle this?

simran66 avatar Jan 24 '18 12:01 simran66