realmmongodb-realm

How to upgrade a local realm to a synced realm?


The alternative title is "How to sync an offline local default realm?"

The default realm is used to allow the app to be used entirely offline. Later when the user decided to sign up the data stored in the default realm should be kept and synced.

Is there a way to upgrade a local realm to a synced realm?


Solution

  • After reading the documentation, https://docs.mongodb.com/realm/sdk/ios/examples/sync-changes-between-devices/#open-a-synced-realm-offline. The only option available is to manually copy the data from the local realm to the newly created synced realm after user sign up.

    You can copy data from a local Realm Database to a synced realm, but you cannot sync a local Realm Database. You must initialize a synced realm with a sync configuration.

    enter image description here

    A similar question was asked in the MongoDB community "Upgrading a Default Realm to a Synced Realm and Vice Versa" and a response from the MongoDB team on 5th June 2021 was copying data between sync and non-sync realms is the only option.

    To copy data from one realm to another on iOS, How to copy objects from the default local realm to a MongoDB synced realm in iOS?

    Relevant Info