I’m looking into a weird conflict problem I get in Android from time to time (doesn’t appear to happen in IOS).
How do I get the conflicts information using the REST API?
I’m looking into a weird conflict problem I get in Android from time to time (doesn’t appear to happen in IOS).
How do I get the conflicts information using the REST API?
Try this:
http://(host):(port)/(db_name)/_changes?include_docs=true&conflicts=true
Is there a way to get only documents that have conflicts ?
Yup,
// Let's find the documents that have conflicts so we can resolve them:
Query query = database.createAllDocumentsQuery();
query.setAllDocsMode(Query.AllDocsMode.ONLY_CONFLICTS);
QueryEnumerator result = query.run();
for (Iterator<QueryRow> it = result; it.hasNext(); ) {
QueryRow row = it.next();
if (row.getConflictingRevisions().size() > 0) {
Log.w("MYAPP", "Conflict in document: %s", row.getDocumentId());
beginConflictResolution(row.getDocument());
}
}
Source: Couchbase Capella for Mobile Developers
THE OG method stems from here:
function(doc) {
if(doc._conflicts) {
emit(doc._conflicts, null);
}
}
Source: Conflict Management
Thanks. I’m using the rest_api and the only_conflicts parameter isn’t documented. I recall when I tried it it didn’t seem to work on android. But I’ll try the view method, that looks good.