Data migration from Realm Cloud to MongoDb

Hello,

It’s been several days since I tried to migrate the data of my application which is on Realm Cloud to MongoDb Realm by following the tutorial https://docs.realm.io/realm-legacy-migration-guide/ but I am completely blocked.

WhenI tried the method described at the end of the tutorial by creating a copyToMongoDb file, I have an error when I run it:

SyntaxError: Invalid or unexpected token
    at wrapSafe (internal / modules / cjs / loader.js: 931: 16)
    at Module._compile (internal / modules / cjs / loader.js: 979: 27)
    at Object.Module._extensions..js (internal / modules / cjs / loader.js: 1035: 10)
    at Module.load (internal / modules / cjs / loader.js: 879: 32)
    at Function.Module._load (internal / modules / cjs / loader.js: 724: 14)
    at Function.executeUserEntryPoint [as runMain] (internal / modules / run_main.js: 60: 12)
    at internal / main / run_main_module.js: 17: 47

I have my application developed in Swift and what I really don’t understand is that I am using the latest version of RealmSwift 10.0 to be able to insert data into MongoDb. However, with RealmSwift 10.0 you cannot connect to Realm Cloud, you have to use an old version for that. How then to get the data on Realm Cloud in order to copy it directly to MongoDb? I have tried downloading the data from Realm Cloud to a local .realm file but I cannot open it using RealmSwift 10.0, is this possible?

Thanks very much for your help, I hope my question is clear enough :slight_smile:

I don’t think the intent is to open the Legacy Realm Cloud with Realm Studio 10.

Assuming you’re using Partial/Query Sync, if you connect to your existing Realm with Realm Studio 3.11, you can File->Export JSON. Alternatively you can connect to it with with an App, iterate over the objects and ‘convert’ them to the current format and save them locally. You could then upgrade that file with Realm Studio 10.

If you select a legacy realm file with v10, here’s what you get.

One the file is of the correct type and all of the new properties are in place _id and partitionKey, it’s pretty straightforward to write that data to the MongoDB Realm server.