Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "_conflicts" property to doc in map function when doc is in conflict #806

Closed
snej opened this issue Jul 6, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@snej
Copy link
Contributor

snej commented Jul 6, 2015

It's poorly documented, but CouchDB adds a _conflicts property to the doc object passed to a map function, when the document is in conflict. From the CouchDB wiki:

Views only get the winning revision of a document. However they do also get a _conflicts member if there are any conflicting revisions. This means you can write a view whose job is specifically to locate documents with conflicts. Here is a simple map function which achieves this:

function(doc) {
  if (doc._conflicts) {
    emit(null, [doc._rev].concat(doc._conflicts));
  }
}

For compatibility it would be good to support this. I don't think it will affect performance: the SQLite engine already has to iterate over all the conflicting revisions, and the ForestDB engine has all the revisions readily available in the VersionedDoc object.

Note: We already support finding conflicts using _all_docs queries. In the REST API, add the query param ?include_conflicts=true or ?only_conflicts=true. In the native API use kCBLShowConflicts or kCBLOnlyConflicts. This is actually more convenient than having to create a special view just to find conflicts.

@borrrden
Copy link
Member

I see you made some commits to the ForestDB storage engine in regards to this ticket, but not SQLite. Was SQLite already working? Or will it not be supported?

pasin referenced this issue Sep 25, 2015
- When updating view index, gather a list of the conflict revisions if any.

- Add index conflict docs performance test to View_Benchmarks.
@pasin
Copy link
Contributor

pasin commented Sep 25, 2015

Yes, I just fixed the reference to the commit and PR. Please look at the PR link above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants