Im using realm/react to build a synced mobile app and used this template to start building:
Now im trying to implement an embedded array of objects like it in the documentation:
My schema looks like this:
import {Realm} from '@realm/react';
import {ObjectId} from 'bson';
export class Media extends Realm.Object {
constructor(
realm,
userId,
collectionType,
type,
genre,
mediaName,
author,
releaseDate,
language,
length,
link,
note,
) {
super(realm, {
_id: new ObjectId(),
userId: userId || '_SYNC_DISABLED_',
collectionType: 'collection',
type: 'test data',
genre: 'test data',
mediaName: 'test data',
author: 'test data',
releaseDate: 'test data',
language: 'test data',
length: 'test data',
link: 'test data',
note: 'test data',
createdAt: new Date(),
access: [userId],
});
}
static Mediaschema = {
name: 'Media_media',
embedded: true,
properties: {
//_id: 'objectId',
author: 'string?',
createdAt: 'string?',
genre: 'string?',
language: 'string?',
length: 'int?',
link: 'string?',
mediaName: 'string?',
note: 'string?',
releaseDate: 'string?',
type: 'string?',
},
};
static schema = {
name: 'Media',
properties: {
_id: 'objectId?',
access: 'string[]',
collectionType: 'string?',
media: {type: 'list', objectType: 'Media_media'},
userId: 'string?',
},
primaryKey: '_id',
};
}
Then i import the schemas like this:
import {createRealmContext} from '@realm/react';
import {Media} from './Media';
export const MediaRealmContext = createRealmContext({
schema: [Media.schema, Media.Mediaschema],
});
but i get the following error that i can’t get rid of:
ERROR Error: Exception in HostFunction: Constructor was not registered in the schema for this Realm
This error is located at:
in AppSync (created by AppWrapperSync)
in Unknown (created by AppWrapperSync)
in UserProvider (created by AppWrapperSync)
in AppProvider (created by AppWrapperSync)
in RCTView (created by View)
in View (created by AppWrapperSync)
in AppWrapperSync (created by App)
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in youria(RootComponent)
ERROR [Error: Exception in HostFunction: Constructor was not registered in the schema for this Realm]
Everything works just like i want it, when i am working with just an plain object without embedding anything.
I would appreciate any help!