title: Check existence of belongsTo() relation in ember data
body: <p>I have a model named List that represents a navigation tree. I should be able to navigate into a child list, and then hit the back button to go back up to the parent list.</p>
  
  <pre><code>import DS from 'ember-data';
  
  export default DS.Model.extend({
    title: DS.attr('string'),
  
    children: DS.hasMany('list', { inverse: 'parent' }),
    parent: DS.belongsTo('list', { inverse: 'children' }) 
  });
  </code></pre>
  
  <p>I determine the "root" level list in my routes file by looking for the list that has no parents.</p>
  
  <pre><code>import Ember from 'ember';
  
  export default Ember.Route.extend({
  
    model(){
      return this.store.findAll('list').then(function(lists){
        return lists.filter(function(list){
          if(Ember.isEmpty(list.get('parent').get('content'))) {
            return true;
          } 
          else {
            return false;
          }
        }).get('firstObject');
      }); 
    }
  });
  </code></pre>
  
  <p>There's a number of things I feel like are wrong about my implementation, even though it works on the initial page load.</p>
  
  <ul>
  <li><code>Ember.isEmpty(list.get('parent').get('content'))</code> completely seems like the wrong way to check for the existence of the parent relationship.</li>
  <li>I feel like I may not be filtering the entire list collection correctly. I'm intentionally calling the index API request so that all lists are loaded, but when I navigate to a child list and hit the back button, the XHR request is made a second time!</li>
  <li>Building on top of that, the filtering <em>only</em> works for the initial page load. If I go down into a list and then hit the back button, the child list persists on the page (no errors or anything!).</li>
  </ul>
  
  <p>What is the <em>right</em> way to check existence of the parent relationship? </p>
  
  <p>Also, what's the <em>right</em> way to filter the entire list to find one record? </p>
  
  <p>Is my ignorance what's causing issues with the back button?</p>