JS exception - undefined type for schema object

I created a schema and imported it into App.js.

    const ConfigSchema = {
      BrandSchema: {
        name: 'Brand',
        primaryKey: 'id',
        properties: {
          id: 'string',
          brandName: 'string',
          icon: 'string',
          partner: 'bool',
          color: {
            brand: 'string',
            brandCustomer: 'string?',
            brandPro: 'string?',
    import ConfigSchema from './models/Schemas';
    const {BrandSchema} = ConfigSchema;

When I create a realm and pass it the schema,

    const realm = new Realm({
      schema: [{name: BrandSchema.name, properties: BrandSchema.properties}],
      deleteRealmIfMigrationNeeded: true,

I get the following error:

Unhandled JS Exception: Error: type must be of type 'string', got (undefined) which tells me it’s not recognizing the schema object.

What exactly is undefined about the schema object? Passing in the whole object, schema: [{BrandSchema}], fails as well. What am I doing wrong?

A lot of the issues I encounter stem from a lack of adequate examples and misunderstanding those that do exist. I finally understand what caused this issue. The constructor was fine. I had to cast the schema ID to a string if I wanted to auto-increment it. :man_shrugging:

const realm = new Realm({
  schema: [BrandSchema],
  deleteRealmIfMigrationNeeded: true,

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