I have been using a partition based synced realm for some time but need to upgrade the schema and MongoDB no longer support partition based sync.
We usually use a javascript program to read the existing local realm file and write the data to the synced realm. This works fine with a partition based realm but fails with the flexible sync realm when trying to open the synced realm.
objectType must be of type 'string', got ([object Object])
It seems that with the flexible synced realm it is necessary to first create subscriptions before it is possible to write to the synced realm, so we added an initial subscription.
const realmConfig = {
schema: target_realm_schema,
sync: {
user: app.currentUser,
//partitionValue: partitionKey,
flexible: true,
initialSubscriptions: {
update: (subs, realm) => {
subs.add(realm.objects(AppPermission), { name: "AppPermission",});
},
rerunOnOpen: true,
},
newRealmFileBehavior: OpenRealmBehaviorConfiguration,
existingRealmFileBehavior: OpenRealmBehaviorConfiguration,
},
};
Any idea what this error could mean ?
It seems that the schema has been created in the MongoDB database so the javascript client was able to connect and initialise the database.