How to add a nested List of objects in Realm "Error: JS value must be of type: object"
<p>I'm trying to create Realm database that has a json array of objects with a nested array of objects.</p>

<p>When I try to add using the code below I always get the error: JS value must be of type: object.</p>

<p>Schemas:</p>

<pre><code>import Realm from 'realm';

class Exercise extends Realm.Object {
}
Exercise.schema = {
    name: 'Exercise',
    primaryKey: 'id',
    properties: {
        id: 'int',
        name: 'string',
        category: 'string',
        bodyPart: 'string',
        levels: {type: 'list', objectType: 'Level'}
    }
};

class Level extends Realm.Object {
}
Level.schema = {
    name: 'Level',
    properties: {
        level: 'int',
        equipments: 'string'
    }
};

export default new Realm({schema: [Exercise, Level, Multiplier]});
</code></pre>

<p>and the method where I'm trying to create the database:</p>

<pre><code> realm.write(() =&gt; {
        let exercise = realm.create('Exercise', {
            id: 209,
            name: 'Dumbbell Overhead Press',
            category: 'Military Press',
            bodyPart: 'Shoulder'
        }, true);

        exercise.levels.push({
            level: 3,
            equipments: 'DB'
        });

    });
</code></pre>

<p>I tried every way possible, putting the array direct in the Exercise creation, etc, I had no success..</p>

<p>Cheers</p>