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 advanced merge strategies #82

Closed
WolframHempel opened this issue Mar 12, 2016 · 2 comments
Closed

add advanced merge strategies #82

WolframHempel opened this issue Mar 12, 2016 · 2 comments
Milestone

Comments

@WolframHempel
Copy link
Member

WolframHempel commented Mar 12, 2016

Add merge strategies that will be executed when the client encounters a version exists error. The following strategies will be supported

C.MERGE_IF_NO_CONFLICT (default) current and incoming version will be merged if neither a value nor a tree conflict exists.

C.LOCAL_WINS the clients current version will be used

C.REMOTE_WINS the incoming update will be used

function(){} - a custom function with the following signature

function( localValue, remoteValue, recordName, recordVersion, callback ) {
    callback( error, mergedVersion );
}

merge strategies can be set in two places:
global as part of the client options

var ds = deepstream( 'localhost:6020', {
    /**
   * @ function mergeStrategy
   */
    mergeStrategy: C.REMOTE_WINS
});

per record on a per record basis

var rec = ds.record.getRecord( 'some/record' );
rec.setMergeStrategy( function(){...});
@WolframHempel
Copy link
Member Author

I'm really in two minds whether this should be done on the client or the server.

Benefits of merging on the client
Greater control, less load on the server, possibility for user interaction / user merging

Benefits of merging on the server
Clients in different languages don't all have to implement merging, centralized, both old and new data of the record is already present, quicker, possibility of database / cache interactions

Love to hear some thoughts...

@anilgulecha
Copy link

@WolframHempel for the sake of this issue can you comment on what was chosen, and point to docs if any?

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

No branches or pull requests

3 participants