Using JSON Schema with Realm

Hello,

I’m planning on using Realm for my new app but the backend and database already exist.
Our backend supports JSON Schema and for now, I’d like to use that. My understanding is that Realm supports JSON Schema but when I try it I’m getting this error:

Possible Unhandled Promise Rejection (id: 0): Error: Failed to read ObjectSchema: name must be of type 'string', got (undefined)

example schema:

const WoSchema = {
  title: 'Contact',
  bsonType: 'object',
  required: ['_id'],
  properties: {
    _id: 'objectId',
    name: 'string',
    address: {
      title: 'Address',
      bsonType: 'object',
      properties: {
        street: 'string',
      },
    },
  },
};

const config = {
  schema: [WoSchema],
};
new Realm(config)

Thanks for the help

Hello! Looks like most of the internet hasn’t seen this before lol. Did you have any luck? I’m getting this myself too (I got this from the Realm app on MongoDB’s website):

const UserData = {
  "title": "UserData",
  "bsonType": "object",
  "required": [
    "_id",
    "partition",
    "name",
    "hasCompletedOnboarding"
  ],
  "properties": {
    "_id": {
      "bsonType": "objectId"
    },
    "partition": {
      "bsonType": "string"
    },
    "name": {
      "bsonType": "string"
    },
    "email": {
      "bsonType": "string"
    },
    "avatarURLString": {
      "bsonType": "string"
    },
    "wishLists": {
      "bsonType": "array",
      "items": {
        "bsonType": "objectId"
      }
    },
    "circleMemberships": {
      "bsonType": "array",
      "items": {
        "bsonType": "objectId"
      }
    },
    "credential": {
      "bsonType": "string"
    },
    "hasCompletedOnboarding": {
      "bsonType": "bool"
    }
  }
};

Seems like its just us two haha XD.
After some more digging I realized that you can convert Realm schema to JSON and visa versa via the app but not with the realm library.
I had to write my own function to convert the JSON data coming from our database to Realm schema