Reordering items with Realm Sync - How are conflicts handled?

How does a Realm List resolve conflicts when multiple devices change the order of items? Is it possible to use a similar algorithm where instead of having a List, each Item has an order field?

Is a Realm List an array of ObjectId; is there a recommended max size after which loading the entire array causes performance issues?

Device Sync uses operational transformation for conflict resolution. I think this is one of the better descriptions / articles I have seen about it:

We also share some details in our docs here:

The TLDR is that lists have the following operations (ArrayInsert, ArrayErase, ArrayMove, ArrayClear) and they each interact differently with each other. When inserting, the main rule is that the intention of the operation is preserved. IE, if client 1 inserts an element at index 1 and client 2 inserts at index 100, the result will be to “transform” client 2’s operation to insert at index 101 (because client 1’s operation shifted the list)

There is no maximum size but we recommend using MongoDB’s best practices and avoiding infinitely sized lists. We regularly see lists in the tens of thousands of elements with no issues though.


1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.