title: Add to Realm List only if doesn't exist
body: <p>I am trying to create a TV Series schema with a list of available Seasons (using RealmJS), I would like to not add duplicate season numbers to the <code>Seasons[]</code> list.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>TvSeries.schema = {
    name: 'TvSeries',
    primaryKey: 'mediaId',
    properties: {
      mediaId: 'string',
      seasons: 'Seasons[]'
    }
  }
  
  Seasons.schema = {
    name: 'Seasons',
    primaryKey: 'seasonNumber',
    properties: {
      seasonNumber: 'int'
    }
  }
  
  realm.write(() =&gt; {
    let season = realm.create('Seasons', { seasonNumber: seasonNumber }, true)
    let tvShow = realm.create('TvSeries', mediaObject, true)
    let seasonsList = tvShow.seasons
    seasonsList.push(season)
  })
  </code></pre>
  
  <p>When I add a new episode (not shown here), it will add the TV Series data and Season again and as there are multiple episodes in a season, it will add to the <code>Seasons[]</code> list multiple times.</p>
  
  <p>My thoughts would be to go through the <code>Seasons[]</code> list and check if it exists, if not then push a new season to it.</p>
  
  <p>Is there a better way of doing this?</p>