I've that system arch: master database named master
and users databases named user1
and user2
. I'm replicating a document from master database to both user1
and user2
dbs. Then users separatelly modify that document in their DBs (for example user1 adds tags:[1, 2]
and user2 adds tags:[3, 4]
fields). Now I'd like to replicate from users databases back to master and merge newly added tags
field so its result into tags:[1,2,3,4]
. Also, I may probably need to run some logic on replication that will make resulted tags to be tags:[1,2,4]
.
What is the right approach?
You don't say how you might want to drop tag "3" in your final result, so it's hard to give a full answer.
There is a lot of good information about various ways to handle just this sort of scenario in the CouchDB Documentation. Designing how you store the data and how you use the stored data to resolve conflicts which includes the following "Suggested code to fetch a document with conflict resolution"
It also notes "This could either be done on every read (in which case you could replace all calls to GET in your application with calls to a library which does the above), or as part of your sweeper code." And it goes on to give a full example in Ruby.
Does that answer all your questions?