title: How to insert objects to Atlas using Relationships with Realm in Kotlin?
body: <p>I have created to RealmObjects: Category and Product, and I have created a one-to-many relationship, where one category has multiple products.
  When I insert a product to Atlas database the category is not showing up. The products are not showing up either in Category collection.</p>
  <p>These are my Realm Objects:</p>
  <pre><code>class Category: RealmObject {
     @PrimaryKey
      var _id: ObjectId = ObjectId.create()
      var name: String = &quot;&quot;
      var image: String = &quot;&quot;
      var products: RealmList&lt;Product&gt; = realmListOf&lt;Product&gt;()
      var company_id: Company? = null
  }
  class Product: RealmObject {
     @PrimaryKey
      var _id: ObjectId = ObjectId.create()
      var name: String? = null
      var quantity: Int? = null
      var price: Float? = null
      var image: String? = null
      var shortDescritpion: String? = null
      var longDescritpion: String? = null
      var barcode: Long? = null
      var category: Category? = null
  }
  </code></pre>
  <p>This is product schema:</p>
  <pre><code>{
    &quot;title&quot;: &quot;Product&quot;,
    &quot;bsonType&quot;: &quot;object&quot;,
    &quot;required&quot;: [
      &quot;_id&quot;,
      &quot;_partition&quot;
    ],
    &quot;properties&quot;: {
      &quot;_id&quot;: {
        &quot;bsonType&quot;: &quot;objectId&quot;
      },
      &quot;_partition&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;name&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;quantity&quot;: {
        &quot;bsonType&quot;: &quot;long&quot;
      },
      &quot;price&quot;: {
        &quot;bsonType&quot;: &quot;float&quot;
      },
      &quot;image&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;shortDescritpion&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;longDescritpion&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;barcode&quot;: {
        &quot;bsonType&quot;: &quot;long&quot;
      },
      &quot;category&quot;: {
        &quot;bsonType&quot;: &quot;objectId&quot;
      }
    }
  }
  </code></pre>
  <p>This is category schema:</p>
  <p>Relationship:</p>
  <pre><code>{
    &quot;products&quot;: {
      &quot;ref&quot;: &quot;#/relationship/mongodb-atlas/bestock-database/Product&quot;,
      &quot;foreignKey&quot;: &quot;_id&quot;,
      &quot;isList&quot;: true
    }
  }
  </code></pre>
  <p>Attributes:</p>
  <pre><code>{
    &quot;title&quot;: &quot;Category&quot;,
    &quot;bsonType&quot;: &quot;object&quot;,
    &quot;required&quot;: [
      &quot;_id&quot;,
      &quot;_partition&quot;,
      &quot;name&quot;,
      &quot;image&quot;
    ],
    &quot;properties&quot;: {
      &quot;_id&quot;: {
        &quot;bsonType&quot;: &quot;objectId&quot;
      },
      &quot;_partition&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;name&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;image&quot;: {
        &quot;bsonType&quot;: &quot;string&quot;
      },
      &quot;products&quot;: {
        &quot;bsonType&quot;: &quot;array&quot;,
        &quot;items&quot;: {
          &quot;bsonType&quot;: &quot;objectId&quot;
        }
      },
      &quot;company_id&quot;: {
        &quot;bsonType&quot;: &quot;objectId&quot;
      }
    }
  }
  </code></pre>
  <p>The database looks like this after I insert a category and a product:</p>
  <p><a href="https://i.stack.imgur.com/GB1N4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GB1N4.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/qLNIC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qLNIC.png" alt="enter image description here" /></a></p>