Pausing a synced Realm

We already have the ability to the ability to pause and resume Sync on the client device so I guess the secret’s out - we’ve broken our business model ! :joy: We also only charge 8 100millionths of a penny per sync minute so I’m not sure we are hiding anything - our pricing would give us right away that our business model is not dependent on Sync. I gave a caveats above about pausing sync because we really don’t know because we don’t have tests for this usage of pausing sync but that doesn’t mean it couldn’t work - have you tried it? What problems does it have? I haven’t seen any issues come across my desk - maybe the issues I mentioned above are not a big deal to your usecase

You’re right - we do have an issue on our feedback portal around pausing Sync but it hasn’t gotten too many upvotes, appears to be 7 at this moment opened a year ago, but even then - we already have an API so…

It really sounds like what could help here is an API that automatically converts the data in a local realm to a synced realm. And it is certainly something I’ve thought about, but as with everything in business, its what you decide to focus on that matters. Right now, we have a humungous backlog that we need to pay down. We use Github issues, market trends, field and support team reports, and yes, the feedback portal to fill in our roadmap - right now, I can’t even find a request for something like this “Realm Import API” on the portal so its difficult to gauge what the user interest would be - although maybe if we counted as a vote every time Kurt asked for it we’d have a good showing! :slight_smile:

All joking aside, it’s difficult to see how this feature would beat out other features like a Flutter SDK, the Kotlin MMP SDK, Cascading Deletes, Full-text Search, Hermes Support, Polymorphism & Inheritance - these are all open-source local-only features that have thousands of requests. But this feature has been on my backlog because I do recognize the need for it and I think it makes sense, it’s just difficult to see how this feature beats out these other massive-impact, massive-reach features in the medium-term.

One thing that is unique to the Realm Import API and that is different from all the other features I mentioned above and which you may not have considered is that this feature can actually all be written in user code, generalized, and productized so that it could be reused across many different users without prior knowledge of their schema. Even though we are open source, you could actually design and build this Import API using just our public APIs. This is a community forum, and we are, well, a community - so perhaps we could start a public Github and enlist others to help build a solution. I’m sure even Realm engineers would be happy to stop by to help answer any questions, troubleshoot, and recommend designs. I can even get you started, this Github repo -
https://github.com/realm/realm-sync-samples/tree/master/08-convert-a-local-realm-to-a-synced-realm

Contains code samples of how to do exactly that, convert the data from a local to a synced realm. It works by leveraging Realm’s dynamic API to read the schema. This is an API that we don’t talk about or document very much because our users want a static API - but we use it to power our Schema migration API and we’ve had users in the past who have built other features of it. Of course, Javascript is a dynamic API definition so it doesn’t need a special API but you get the idea.

The code is a bit old, so it’d need to be updated but the design pattern would remain the same; first open the realm and scan the schema of the source realm and instantiate it in the target realm, next copy all objects from the source realm to the target realm by iterating through the objects but keep special attention to links such as a one-to-one or one-to-many, you can see that in the code we key off this type in the code (else if (prop['type'] == "list") then finally do a second pass across the target realm to fill in those links and lists completing the relationships.

I hope this helps -

Best,
Ian

1 Like

Update here - we have released an API in Swift to automatically convert a non-sync realm to sync realm, have at it!

2 Likes

Thanks Ian. Very impressed to see this eventuate. Is there any possibility we can see this functionality in the realm-js version so we can use within React Native?

@_Mark Yes the implementation is under way for the feature to be released in the other SDKs and I expect it to be done in the next few weeks. cc’ing the JS team who may be able to provide an update when they are ready @Franck_Franck @Kenneth_Geisshirt

1 Like

Hello. Are there any updates on this topic? 2 years have passed since the last discussion, perhaps something has changed?

@Ian_Ward
I’m currently trying to prevent the sync from happening if a user gets back online so I can check if a new version (potentially with breaking changes) has been released, so I can inform the user to update their app before they can sync their data.
By what I see in the discussion, even the mixed solution would not work in that case.
Isn’t there a way to “allow/disallow” realm from reaching the internet? Should I force the URL of the realm provider to an empty domain so it tries to sync to an unknown endpoint until I give it the go when the version number don’t mismatch?
That is an extremely basic feature, I can’t imagine adding a flag to pause the sync would be that complicated.
PS: my experience with Realm and its documentation has been, like everyone conveyed here, nothing but catastrophic, having to guess and lose sleep over what could go wrong with Realm even in 2024 while our business is at risk because of that. I hope you’ll have a better solution to suggest 3 years later.