Concept on realm - with local and flexibleSync usage

Hi, I have a basic conceptual question about using relam with local and flexibleSync usage.

Starting point:
My requirement is that I want to offer the user only a local realm database in the Free version. However, if the customer decides to upgrade to a Pro version, I want them to be able to share the data with other users via flexibleSync. Btw. if relevant the app is developed based on Flutter.

My issue is that I cannot “simply” convert a local relam database to flexibleSync. Instead, I need to create a flexibleSync database and transfer the data from the local database to the flexibleSync database. Also if the user decides to go back to free version of the app I need to transfer the data back.

My question about the concept:
Is it possible and reasonable to do without the local Relam database and use only the flexibleSync database from the beginning, but with the setting that no data is synchronised in the background. Only when the user activates the Pro version are rules created that define that certain data should be synchronised. It is clear to me that I need a user for flexibleSync, but that user can be anonymous.

Is it feasible concept from realm point of view? From my point of view it makes sense in any case, because I can avoid the implementation of two realm databases (local and flexibleSync) and the architecture of the application is simplified considerably as a result.

We don’t support converting local to flexible sync realms.
In fact convert support is coming in the next Realm Flutter/Dart release, but the local to flx sync support will not be there.
What you can do, if and only if you expect people to be using the local realms for short period of time with a limited data operations like add and remove is, you can use Configuration.disconnectedSync.
This configuration can be used to open a synced realm locally without sync enabled. But there is a drawback that it will persist any data operations that are made in the realm and that will constantly increase the realm size cause it will keep history records of how data was changed. This history will not be pruned. This is done so on the next Configuration.flexibleSync open, the data can be synced correctly.
So in order for this to work you can open a disconnectedSync realm and afterwards just change the configuration you are using to flexibleSync, to enable syncing of the data.

The more robust approach currently, that will not increase the file size dramatically over time, is to just use local realm and transfer the data manually into a synced realm when the user activates the Pro version.

We have plans on supporting what you describe in the future, but I can’t comment when it may be available.


1 Like

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