CouchDB _design Document Conflict Detection

I know that CouchDB identifies documents that conflict after replication. Does CouchDB handle conflicting definitions differently for _design documents than for regular documents? For example, I am editing a _design document in DB1. Then I modify the same _design document in DB2. Then I replicate DB1 to DB2. I would expect CouchDB to detect a conflict, however, after replication, Couch does not return conflicts.

+4
source share
1 answer

The design documentation exactly matches the normal documents, so the name is "project documents" instead of "couch programs" or such.

If you make identical changes to identical documents in different databases, you will have no conflicts. Running couchapp push could create this situation if you couchapp push the same application to two different databases (and they start with the same _rev ).

Otherwise, you will receive a conflict, regardless of whether it is framed or not. Of course, the couch will β€œpromote” one revision as a canonical version, but if you look at _conflicts in the view, you will see them. (To view design documents in a view, you must also include the include_design parameter.)

 { "_id": "_design/example" , "views": { "conflicts": { "options": {"include_design": true} , "map": "function(doc) { if(doc._conflicts) emit(doc._id, doc._conflicts); }" } } } 

Find conflicting ddocs by scanning a range of keys:

 ?startkey="_design/"&endkey="_design0" 
+3
source

Source: https://habr.com/ru/post/1344955/


All Articles