why deepstreamHub? compare us getting started feature roadmap faq
use cases pricing
blog contact

Allows users to reconcile record versions in case of data-conflict ( out of sync record versions )



class func merge(_ record: Record, remoteValue: JsonElement, remoteVersion: Int) throws -> JsonElement
argument type description
record Record Used to retrieve the local version via record.version() and data via record.get()
remoteValue JsonElement The remote value on the platform
remoteVersion int The remote version on the platform, used to find out if the remote is ahead of the local

Whenever a version conflict occurs the MergeStrategy set via Record.setMergeStrategy(_:) will be called to merge the data and send the data back to the platform.

This is mainly used for scenarios such as when working on very collaborative records where messages cross on the wire, or for connection drops where the client still updates records in an offline mode.

Throw an error if the merge fails, but keep in mind that this only means it will postpone the merge conflict until the next remote/local update.