Can CouchDB's filtered replication be set to replicate not only the most recent version of every document, but also the last 100 revisions of each document?
I want this feature, because I intend to allow each app instance to pick which recent revision (revisions will be coming from multiple sources, each having a different level of accuracy/trustworthiness) is the most accurate, so I need more than one revision available in each database instance.
The specific use-case is as follows:
CouchApp 1 contains a database of data on all congregations of one Reformed denomination.
CouchApp 2 contains a database of data on all congregations in all Reformed denominations worldwide.
CouchApps 1 & 2 are set up to replicate bidirectionally to keep in sync with each other, but CouchApp 1 requests only one denomination's data from CouchApp 2's denomination replication filter.
User 1 is anonymous, so relatively untrusted, and user 2 is the admin of CouchApp2, so has a high level of authority/trustworthiness. Both CouchApps are set to trust recent data 2/3 more than authoritative data.
First (in the order of time), authoritative user 2 enters 10 revisions of congregation data about congregation 1 into CouchApp 2 (all denominations). Second (in the order of time), anonymous user 1 enters 10 revisions of congregation data about congregation 1 into CouchApp 1 (one denomination).
Bidirectional replication occurs.
CouchApp 2 (all denominations) displays user 1's data by default, because that data is more recent. But, because user 1 only entered some (but not all) fields of congregation 1's data, CouchApp 2 displays user 2's data for all the other fields.
I'm open to being told it's not worthwhile for an app to replicate more than one revision, or to evaluate the accuracy of users' input after replication (it could be done before replication instead), or to evaluate that accuracy at all.
Sorry, you cannot replicate old revisions directly. The _rev
number's sole purpose is for MVCC and not designed for tracking revision history. That being said, it's not impossible to do this.
Consider storing old revisions as JSON attachments on a document itself. This will have them replicated right along with the rest of the document. In addition, there are other strategies that people have devised for conquering this problem. (Google around and you can probably find even more)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With