Save an Embedded Object Data

I’m trying to initialize a realm with a schema which contain embedded Objects, but I always get Exception error

Error: Exception in HostFunction: Schema validation failed due to the following errors:
- Property 'Permits.other_passangers' of type 'array' has unknown object type 'permit_other_passangers'        
- Property 'Permits.quantity' of type 'array' has unknown object type 'permit_quantity'

here is my schema file:

const PermitSchema = {
  name: 'Permits',
  properties: {
    _id: 'objectId?',
    __v: 'int?',
    _partition: 'string',
    cargo_type: 'string?',
    location: 'string?',
    other_passangers: {type: 'list', objectType: 'permit_other_passangers'},
    quantity: {type: 'list', objectType: 'permit_quantity'},
    where_to: 'string?',
    updatedAt: 'date?',
  primaryKey: '_id',

const permit_other_passangersSchema = {
  name: 'permit_other_passangers',
  embedded: true,
  properties: {
    name: 'string?',
    phone: 'string?',

const permit_quantitySchema = {
  name: 'permit_quantity',
  embedded: true,
  properties: {
    amount: 'int?',
    unit: {type: 'string?', enum: ['ndoo', 'djaba', 'pieces', 'gunia']},

export default PermitSchema;

I’ve tried to follow the docs here but I can’t find a work around, though removing those fields seems to fix the problem.

I will appreciate any help to point me in the right direction.

1 Like

I figured it out, it was a silly mistake. I was not passing embedded schemas during realm initialization.

so I had to export all schemas

const config = {
schema: [Permit.schema, permit_quantitySchema , permit_quantitySchema ]

So far so good,

1 Like

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