Resolving conflicts in CBL via the rest api

Apologies if this has been asked before, but I can’t quite find a suitable explanation to help me.

I’m using CBL via the rest API. I’ve written a view to give me all the conflicts (because I couldn’t find any other way to do it - don’t think the docs are correct).

conflicts: {
   "map": function(doc) {
     if(doc._conflicts) {
       emit(doc._conflicts, doc);
     }
   }.toString()
}

I’m getting a conflict back and want resolve it by just keeping the version thats on the server and discarding and local revision. I guess my first question is, how do I know which version is the winning server version?

Secondly. If I have been making many changes to a document in conflict and have several revisions I want to get rid of in order to get back to the server version - how do I delete them? is there an order in which I need to do it?

Or is there a shortcut? All I really want is the server version.

An example of the issues I’m having. I’ve got the following conflict and have tried separately to delete revisions 29 and 30, but on each attempt I just get a 409 response.

{ doc: null,
id: 'bd8f1839f60512ee0b0f8fd899b76e8d',
key: [ '2-30c3d2007a86d11b6c3283048965e33d' ],
value: 
{ account_alias: '',
 readers: 
  [ 'd64ffd61-57d2-474a-83c0-64da8bfe85e7',
    '4c6302a5-609a-4be8-8ae4-f8c5f6b89671' ],
 owner: 'd64ffd61-57d2-474a-83c0-64da8bfe85e7',
 type: 'public-profile',
 account_id: 'f31ce8439f35df4e47471e93593576ae',
 _id: 'bd8f1839f60512ee0b0f8fd899b76e8d',
 _rev: '2-92caefaa36001f6663e10cf0f9d88896',
 _local_seq: 1015,
 _conflicts: [ '2-30c3d2007a86d11b6c3283048965e33d' ] } }

If I query the sync_gateway direct I see its at version 5-0c…

@nick-couchbase,

This is sorta a classic DB and particularly a CouchDB problem.
Can you add a new element called audit? Like below:

{ "_id":"12345", "_rev":"14-coaues9ao595321", "data":"stuff", "audit":{ "createdBy":"bob", "createdDateTime":"some date1", "createdAt":"iphone 4", "updatedBy":"admin", "updatedDatetime":"some date 2", "updatedAt":"appserver-9" } }

What does this mean??

{ _id: 'c105d6dee5139889df38a0d8580ba626',
  _conflicts: [ '6-31331f58af4371a386dbf5c0d0b05b9b' ],
  _rev: '6-31331f58af4371a386dbf5c0d0b05b9b',
  ...

The server version is also at 6-31331f58af4371a386dbf5c0d0b05b9b. What is the conflict?