You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Operations: Server: How to Modify a Conflict Solver

The conflict solver allows you to set a conflict resolution script for each collection or resolve conflicts using the latest version.

To modify the solver configuration, use ModifyConflictSolverOperation.


public ModifyConflictSolverOperation(
    string database, 
    Dictionary<string, ScriptResolver> collectionByScript = null, 
    bool resolveToLatest = false)

public class ScriptResolver
    public string Script { get; set; }

database string Name of a database
collectionByScript Dictionary<string,ScriptResolver> Per collection conflict resolution script
resolveToLatest bool Indicates if a conflict should be resolved using the latest version
Return Value
Key Name of database
RaftCommandIndex RAFT command index
Solver Saved conflict solver configuration

Example I

// resolve conflict to latest version
ModifyConflictSolverOperation operation = 
    new ModifyConflictSolverOperation("Northwind", null, resolveToLatest: true);

Example II

// resolve conflict by finding max value 
string script = @"
var maxRecord = 0;
for (var i = 0; i < docs.length; i++) {
    maxRecord = Math.max(docs[i].maxRecord, maxRecord);   
docs[0].MaxRecord = maxRecord;

return docs[0];";

ModifyConflictSolverOperation operation = 
    new ModifyConflictSolverOperation("Northwind", new Dictionary<string, ScriptResolver>
        { "Orders", new ScriptResolver { Script = script} }
    }, resolveToLatest: false);